Skip to content
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

Closed
ghost opened this issue Dec 9, 2015 · 6 comments
Closed

Wrong display resolution (Android) #9371

ghost opened this issue Dec 9, 2015 · 6 comments
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc. Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement.
Milestone

Comments

@ghost
Copy link

ghost commented Dec 9, 2015

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)

"Mozilla/5.0 (Linux; Android 4.4.2; IQ1010 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.76 Safari/537.36"

(piwik.php parameter)

&res=1280x800

But...

This displays an invalid resolution (800.08129 ?!?!):

(user agent)

"Mozilla/5.0 (Linux; Android 4.4.2; Lenovo A5500-H Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Safari/537.36"

(piwik.php parameter)

&res=800.0812929868698x1216.7625653743744

Looks like there is a rounding error?

@tsteur
Copy link
Member

tsteur commented Dec 9, 2015

Is it maybe somehow related to #8643 or #4663 ?

Is this using one of our Android or Java Tracking SDKs or via JavaScript in the browser?

@ghost
Copy link
Author

ghost commented Dec 9, 2015

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.

@ghost
Copy link
Author

ghost commented Dec 9, 2015

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 :)

@tsteur tsteur added Bug For errors / faults / flaws / inconsistencies etc. Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement. labels Dec 9, 2015
@tsteur
Copy link
Member

tsteur commented Dec 9, 2015

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);

@tsteur
Copy link
Member

tsteur commented Dec 9, 2015

Moving it into 2.15.1 for now as it might lead to invalid tracking data

@mattab
Copy link
Member

mattab commented Mar 10, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. Help wanted Beginner friendly issues or issues where we'd highly appreciate community's help and involvement.
Projects
None yet
Development

No branches or pull requests

2 participants