1 year ago

#375389

test-img

Luis A. Florit

Screen width battle: Webview vs Firefox vs Chrome

I made a simple web browser with a webview in Android, but for some reason I am getting inconsistent pixelRatios. I also got a wrong UserAgent, but I fixed that already.

I tested this in a 1080x2400 phone with javascript using window.devicePixelRatio (PR), window.innerWidth (IW), screen.width (W), window.innerHeight (IH), screen.height (H) (you can check here). This is what I got:

Firefox     PR=2.6087 IW=414 W=414 IH=783 H=920
Chrome      PR=2.625  IW=412 W=412 IH=778 H=915 
Webview     PR=2.625  IW=412 W=412 IH=834 H=915

Indeed H/W = 2400/1080 = 2.2222. But I am confused with the different pixelRatios.

For Firefox, it seems it is doing 1080/414, while for Chrome it is doing 1080/412.

So, why is the difference 412 vs 414? Which one should be trusted?

android

browser

webview

screen

pixel-ratio

0 Answers

Your Answer

Accepted video resources