Bug 210009 - window.innerHeight is broken in WKWebView with viewport-fit=cover
Summary: window.innerHeight is broken in WKWebView with viewport-fit=cover
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Local Build
Hardware: iPhone / iPad iOS 13
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-04-04 13:01 PDT by evangun2001
Modified: 2022-03-17 00:22 PDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description evangun2001 2020-04-04 13:01:53 PDT
When `viewport-fit=cover` is used in Cordova with the WKWebView plugin, `window.innerHeight` reports a wrong value.
Instead of reporting the proper window height, it reports the window height MINUS the safe areas insets.

Even a minimalistic snippet will demonstrate the issue: https://gist.github.com/louisameline/d5ae03b07db8185051346b8da55a2704

The issue happens only if the content of the page is smaller in height than the window height.
Exemple: if my iPhone window is 812px high, and the "natural height" of my page is 500, `window.innerHeight` returns 734 (= 812 - 44 top safe area inset - 34 bottom safe area inset). If my page content is 750px high, `window.innerHeight` returns 750, and if my page content overflows the window, `window.innerHeight` returns 812.

Additional notes:
- The `window.innerHeight` value is not longer false after a rotation of the screen
- The bug does not happen in Chrome, Safari, UIWebView, Ionic WKWebView, Capacitor
- It was previously brought to the Cordova team, who suggested to report it here: https://github.com/apache/cordova-plugin-wkwebview-engine/issues/108

Thanks
Comment 1 evangun2001 2020-04-04 13:05:30 PDT
Tested on iPhone XS, iOS 13.4, Xcode 11.4, cordova-ios 5.1.1, cordova-plugin-wkwebview-engine 1.2.1
Comment 2 Radar WebKit Bug Importer 2020-04-06 22:55:17 PDT
<rdar://problem/61378008>
Comment 3 ik 2022-03-16 08:39:44 PDT
This also affects standalone web apps, see https://bugs.webkit.org/show_bug.cgi?id=237961