Closed ghost closed 8 years ago
Is it maybe somehow related to https://github.com/piwik/piwik/issues/8643 or https://github.com/piwik/piwik/issues/4663 ?
Is this using one of our Android or Java Tracking SDKs or via JavaScript in the browser?
Thank you for your quick reply.
I don't think its related to #8643, but #4663 could be related, unfortunately I can't tell for sure because they don't list any examples.
This is via javascript in the browser.
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: https://github.com/piwik/piwik/issues/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?