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

getScreenResolution is zoom dependent for IE and FF #98

Open
mp31415 opened this issue Dec 10, 2015 · 14 comments
Open

getScreenResolution is zoom dependent for IE and FF #98

mp31415 opened this issue Dec 10, 2015 · 14 comments
Labels

Comments

@mp31415
Copy link

mp31415 commented Dec 10, 2015

In Chrome getScreenResolution (screen.height, screen.width, screen.availHeight, screen.availWidth) is zoom independent, however in IE and FF these values change upon zoom in/zoom out. (Not sure about Safari/Opera). It makes fingerprint less stable I think. The extra code I use to deal with the issue is the following:

getScreenResolution: function(keys) {
    this.getScreenResolutionOrAvail(keys, screen.width, screen.height);
    this.getScreenResolutionOrAvail(keys, screen.availWidth, screen.availHeight);
    return keys;
},
getScreenResolutionOrAvail: function(keys, saw, sah) {
  var res;
  if(saw && sah) {
      var zoom = 1;
      if (this.isIE()) {
          zoom = screen.deviceXDPI / screen.systemXDPI;
          zoom = this.round5(zoom*100)/100;
      }
      else if (this.isFF()) {
          zoom = window.devicePixelRatio;
      }
      if (zoom != 1) {
        sah = this.round10(sah * zoom);
        saw = this.round10(saw * zoom);
      }
      res = (sah > saw) ? [sah, saw] : [saw, sah];
  }
  if(typeof res !== "undefined") { // headless browsers
    keys.push(res);
  }
  return keys;
},
round5: function (x)
{
    return Math.round(x/5)*5;
},
round10: function (x)
{
    return Math.round(x/10)*10;
},
@Valve
Copy link
Member

Valve commented Dec 11, 2015

Thanks for the code, last time I checked into this, I couldn't make FF return resolution in a stable way when zooming in/out. I'll look into it.

@Valve
Copy link
Member

Valve commented Dec 19, 2015

@mp31415
Thanks for your code, it's a very good start. It returns incorrect resolution for Retina display (tested on FF + MBP 2013 retina), but it's fixable. I have yet to test it on IE browser, but I think it should work there as well. 👍

I have also referenced your code in this SO answer: http://stackoverflow.com/questions/30557404/get-screen-resolution-independent-of-zoom-in-firefox/34368907#34368907

Please let me know if you're OK with it.

@Valve
Copy link
Member

Valve commented Dec 20, 2015

I've modified your code slightly (mostly cleanup/readability) and added it to the dev branch. The screen resolution now is independent on zoom. However, the canvas FP is different for FF on different zooms. I have opened a separate issue for this.

@Valve Valve closed this as completed Dec 20, 2015
@francescocristallo
Copy link

The same problem occurs with Microsoft Edge as well.
the isIE method do not works for Edge, I use this:

var isEdge = function () {
            if (navigator.userAgent.match(/edge/i)) { // Edge
                return true;}
            return false;
    };

Testing with IE here:
http://valve.github.io/fingerprintjs2/

I still have the same problem, doing the zoom, the Fingerprint change.
During my internal tests, the resolution is not stable and vary slightly. This rounding seems to not working well at least on my pc.
Windows 10, IE11,

No ZOOM: 2500x1400
150% ZOOM: 2560x1440
400% ZOOM: 2540x1430

@Valve
Copy link
Member

Valve commented Dec 20, 2015

@LightCrystal thanks for letting me know. I don't have a Windows device with Microsoft Edge on it, only with IE 11 (where zooming is working fine). Please submit a separate issue so that other people with Edge could see it and potentially fix.

@mp31415
Copy link
Author

mp31415 commented Dec 21, 2015

@Valve regarding code referencing. Absolutely. We all owe you for this great piece of software. So thanks a lot.
Regarding Microsoft Edge. I do have Win10/Edge and tested the code (the one I submitted above). It worked fine for me, but my screen resolution is 1920x1200. Cannot test with 2500x1400. This resolution thing becomes messy pretty quick :(.

@Valve
Copy link
Member

Valve commented Dec 21, 2015

OK, so the issue is big resolutions, where rounding errors start to interfere. Maybe we should add additional scaling factor based on resolution? I don't have a device to test it unfortunately though

@Valve
Copy link
Member

Valve commented Dec 21, 2015

I've just upgraded my old laptop to Windows 10 and tested on MS Edge. The FP is changing depending on the zoom. The laptop has the resolution of 1600x1200, so I will take a look into it.

@Valve Valve reopened this Dec 21, 2015
@Valve Valve added this to the v.3.0 milestone Aug 8, 2016
@Valve
Copy link
Member

Valve commented Aug 8, 2016

Moving this issue to v3, because it's much harder to fix reliably, than I anticipated.

@Valve
Copy link
Member

Valve commented Aug 3, 2019

3 years later, and it's still an issue, which I don't know how to solve reliably.
This is just a status update.
We can automatically ignore screen resolution on FF when zoom level is != 1,
What do you think @jonashaag ?

@altayevrim
Copy link

Yeah. I think that should be done. I just tested on FF and this still exists.

@Valve
Copy link
Member

Valve commented Jul 9, 2020

https://developer.mozilla.org/en-US/docs/Web/API/Visual_Viewport_API
This may be how we can solve this in FF.

For IE - we'll be dropping the IE support in V3.

@Finesse
Copy link
Member

Finesse commented Oct 16, 2020

@Valve The issue is still relevant for v3. I think we should solve it.

@Finesse Finesse added the bug label Oct 16, 2020
@Valve
Copy link
Member

Valve commented Oct 16, 2020

@Finesse I agree, but I don't know how. Also we need to confirm if it's still an issue in Edge based on Chromium.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants