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

piwik.JS: devicePixelRatio detection covers only Apple devices #4663

Open
nkuehn opened this issue Feb 11, 2014 · 6 comments
Open

piwik.JS: devicePixelRatio detection covers only Apple devices #4663

nkuehn opened this issue Feb 11, 2014 · 6 comments
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.

Comments

@nkuehn
Copy link

nkuehn commented Feb 11, 2014

The devicePixelRatio detection in https://github.com/piwik/piwik/blob/master/js/piwik.js#L2242 makes a simple assumption that only Apple Retina devices have a physical screen resolution that differs from the logical (CSS pixel) resolution.

That leads to the issue that e.g. most Android hi-res devices aren't correctly detected and neither Win8 ones.

You can find a list of real CSS Pixel ratios here: http://en.wikipedia.org/wiki/List_of_displays_by_pixel_density Unfortunately not all Devices are configured on 1 1.5 2 2.5 3 etc... but some use in-between ratios.

My suggestion would be to use this (established) polyfill instead of the UA regexp:
https://github.com/tysonmatanich/GetDevicePixelRatio/blob/master/getDevicePixelRatio.js

but I would add a rounding to 0.5 precision to not spam the Data with random outliers.

did I miss something? I'm not sure how such a change affects backwards compatibility of the data. If backwards compatibility is an issue (have to think about retina displays on desktops, too!), An alternative would be to define "res" as CSS resolution and report devicePixelRatio separately (See my P.P.S. below).

Greets, interested to hear what you think.
Nikolaus

P.S.: Concerning the devicesDetection Plugin: I think it would be a never-ending uphill battle to try to maintain an always-up-to-date mapping of UA strings to devicePixelRatios on the server, which would be inherently unreliable all the time as Vendors are starting to anonymize the UA strings of the devices more and more.

P.P.S.:

  • As a web programmer, The thing I would be most interested in is to analyze CSS Pixel Screen sizes and devicePixelRatios separately (and the devicePixelRatio as such and not translated into a resolution). Reasoning behind: I code against CSS pixels and when I'm done with that I need to create image resources in varying devicePixelratios (or decide on a best compromise which would be 2). But that's a different issue.
    Keywords: js resolution detection
@mattab
Copy link
Member

mattab commented Feb 15, 2014

If there is a bug in the devicePixelRatio we'd like to fix it for sure!

Could you give some examples of how changing the code, would change the data?

ie. what use case/bug would it solve?

@mattab
Copy link
Member

mattab commented Feb 15, 2014

Concerning the devicesDetection Plugin: I think it would be a never-ending uphill battle to try to maintain an always-up-to-date mapping of UA strings to devicePixelRatios

We only maintain regular expressions to detect devices, brands, models, etc. we don't maintain list of user agents, except of course in our extensive test suite which tests more than 1000 user agents after each commit. It will be a challenge to maintain this list for sure, but we call on the community to help us improve it over time and add new devices and models and brands and browsers and operating systems.

@nkuehn
Copy link
Author

nkuehn commented Feb 17, 2014

ok, I'll try to isolate the issue with the android resolutions tracked on a local installation.

Another possible cross-check whether this is actually a bug would be to take a real-world dataset (like the piwik forums and/or website) and segment some popular hi-res Android devices (from "device model" report, e.g. the GT - I9_5_0_5 against the screen resolutions tracked for them via the Javascript side of Piwik. If the resolution tracked for that Model is Full HD my bug description may be wrong because that's the way the iOS devices are tracked, too (real physical resolution).

I unfotunately don't have such a dataset yet because we're not yet live with piwik.

@nkuehn
Copy link
Author

nkuehn commented Feb 17, 2014

remove the underscores, I was fighting with the trac spam filter

@mattab
Copy link
Member

mattab commented Feb 22, 2014

ie. what use case/bug would it solve? we would need to know whether it is a bug or a new feature request, i'm not sure yet...

@nkuehn nkuehn added this to the Future releases milestone Jul 8, 2014
@mattab mattab modified the milestones: Mid term, Long term Nov 28, 2014
@mattab mattab modified the milestones: Long term, Mid term Dec 5, 2016
@sgiehl
Copy link
Member

sgiehl commented Nov 18, 2017

devicePixelRatio won't be considered at all anymore. See #10289
We maybe could start tracking the value of devicePixelRatio as separate value in the future and add an additional report showing calculated resolutions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.
Projects
None yet
Development

No branches or pull requests

3 participants