New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong display resolution (Android) #9371
Comments
I'm not familiar with piwik, but I had some free time so I took a look at piwik.js. It seems the line 4775 is one culprit: browserFeatures.res = screenAlias.width * devicePixelRatio + 'x' + screenAlias.height * devicePixelRatio; If the devicePixelRatio is... a strange float number, like 1.0001 then multiplying 800 with that, we end up with the wrong number as seen in my real example above. Maybe the devicePixelRatio is either incorrectly reported by the browser, or the calculation should round down the numbers when the ratio is a float and not 1,2 or 3. Or maybe I've got it all wrong :) |
We could definitely do something there as it is easy to do. I'd suggest something like devicePixelRatio = parseFloat(devicePixelRatio).toFixed(3); // I think we could even do "devicePixelRatio.toFixed(2)" but better we make sure to work with int or float. Maybe we would do it only if it already is a float and not an "int"
var width = parseInt(screenAlias.width,10) * devicePixelRatio;
var height = parseInt(screenAlias.height, 10) * devicePixelRatio;
browserFeatures.res = parseInt(width, 10) + 'x' + parseInt(height, 10); |
Moving it into 2.15.1 for now as it might lead to invalid tracking data |
Fixing it in piwik.js is useful but it looks like we need to also sanitise the data in the Tracking API, see the similar new issue: #9911 |
I've noticed many resolutions are reported wrongly, mainly for Android devices. I'm not sure if this is due to a bug in piwik, or if its due to a fake browser on the client side.
For example, this displays the correct resolution (1280x800):
(user agent)
(piwik.php parameter)
But...
This displays an invalid resolution (800.08129 ?!?!):
(user agent)
(piwik.php parameter)
Looks like there is a rounding error?
The text was updated successfully, but these errors were encountered: