Bug 221279 - [iOS] window.screen.{width, height} are incorrect on iPhone 12 in WKWebView
Summary: [iOS] window.screen.{width, height} are incorrect on iPhone 12 in WKWebView
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Layout and Rendering (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-02-02 12:09 PST by Ali Juma
Modified: 2021-05-26 05:26 PDT (History)
6 users (show)

See Also:


Attachments
Test case from crbug.com/1172787 (475 bytes, text/html)
2021-02-02 12:09 PST, Ali Juma
no flags Details
screenshot WebKit ToT (299.57 KB, image/jpeg)
2021-05-13 10:56 PDT, zalan
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ali Juma 2021-02-02 12:09:38 PST
Created attachment 419046 [details]
Test case from crbug.com/1172787

On iPhone 12 on iOS 14.4, window.screen.{width, height} is incorrect in non-Safari WKWebView, but correct in Safari.

Specifically, in WKWebView (tested in Chrome, Edge, and Firefox on iOS):
window.screen.width is 375 and window.screen.height is 812

But in Safari:
window.screen.width is 390 and window.screen.height is 844

This bug was originally reported at https://crbug.com/1172787
Comment 1 Radar WebKit Bug Importer 2021-02-09 12:10:12 PST
<rdar://problem/74152923>
Comment 2 zalan 2021-05-13 10:56:27 PDT
Created attachment 428532 [details]
screenshot WebKit ToT

I am seeing 375x812 on trunk WebKit.
Comment 3 zalan 2021-05-13 10:56:47 PDT
(In reply to zalan from comment #2)
> Created attachment 428532 [details]
> screenshot WebKit ToT
> 
> I am seeing 375x812 on trunk WebKit.
In Safari that is.
Comment 4 kirill.kandalov 2021-05-25 06:55:17 PDT
Do you check with "Zoom" feature on or off? As it affects the values that you'll see.

Check this article that states when each resolutions should appear:
https://hacknicity.medium.com/how-ios-apps-adapt-to-the-various-iphone-12-screen-sizes-e45c021e1b8b
"Standard Zoom
Unlike the iPhone 12 mini, the iPhone 12 and 12 Pro introduce a completely new resolution of 390×844 points at their native resolution"
And
"Apps built with Xcode 12.0 or earlier will see a zoomed up iPhone 11 Pro resolution of 375×812 when run on the iPhone 12 or 12 Pro at its native resolution"

BTW all the internet is full of claiming that iOS window should be 390x844.
E.g. https://yesviz.com/devices/iphone-12/
https://useyourloaf.com/blog/iphone-12-screen-sizes/

Back to the bug, is the wrong resolution in non-Safari WKWebView due to compilation with old XCode or for other reason (i.e. bug)?
Comment 5 Tim Horton 2021-05-25 10:51:52 PDT
<rdar://78465520>
Comment 6 Ali Juma 2021-05-26 05:26:30 PDT
I re-tested on the currently shipping versions of Chrome, Firefox, and Edge on iOS, and they all now show the same result as Safari on iOS 14.5 (390x844).

For Chrome at least, this seems to have been fixed by building with Xcode 12.1+ rather than Xcode 12.0.

I think the only thing remaining to figure out here is Comment 2, that is, why trunk WebKit is reporting 375x812 rather than 390x844.