@nkuehn opened this issue on February 11th 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 commented on February 15th 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 commented on February 15th 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 commented on February 17th 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. theGT - 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 commented on February 17th 2014

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

@mattab commented on February 22nd 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...

Powered by GitHub Issue Mirror