Bug 185886 - Incorrect window size following window.onresize for WKWebView using Auto Layout
Summary: Incorrect window size following window.onresize for WKWebView using Auto Layout
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: Safari 11
Hardware: Unspecified iOS 11
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-22 14:12 PDT by Justin D'Arcangelo
Modified: 2019-02-06 09:18 PST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Justin D'Arcangelo 2018-05-22 14:12:10 PDT
On iOS, the `window.onresize` event fires in a WKWebView when the device switches orientation. However, if the WKWebView is positioned WITH Auto Layout, `window.innerWidth` and `window.innerHeight` will report incorrect values from within the `window.onresize` event handler. But, if the WKWebView is positioned manually WITHOUT using Auto Layout, `window.innerWidth` and `window.innerHeight` will report correct values in the event handler.

This bug was found in Firefox for iOS when viewing maps.google.com and rotating the device orientation as reported here: https://bugzilla.mozilla.org/show_bug.cgi?id=1463058

I've created the following JSBin for testing the result of observing the `window.onresize` event when rotating the device orientation:

http://output.jsbin.com/regipul

Then, I tested that JSBin in a minimal WKWebView iOS app both WITH and WITHOUT Auto Layout and observed the following:

WKWebView WITH Auto Layout:
1.) Portrait  - 375x603 (initial load)
2.) Landscape - 375x343
3.) Portrait  - 375x343

WKWebView WITHOUT Auto Layout:
1.) Portrait  - 375x603 (initial load)
2.) Landscape - 667x311
3.) Portrait  - 375x603

As you can see, in the WKWebView using Auto Layout, the `innerWidth`/`innerHeight` values remain the same following the first `window.onresize` event. However, this problem is not exhibited when positioning the WKWebView manually without Auto Layout.

This problem is not seen in Mobile Safari. Presumably, it is not using Auto Layout.
Comment 1 Lucas Forschler 2019-02-06 09:18:58 PST
Mass move bugs into the DOM component.