Bug 255852 - [css-values] Viewport units are often wrong in IABs using WKWebView
Summary: [css-values] Viewport units are often wrong in IABs using WKWebView
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: Safari 16
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-04-23 23:31 PDT by Johannes Odland
Modified: 2023-05-01 18:39 PDT (History)
5 users (show)

See Also:


Attachments
Viewport unit test in Facebook IAB (small viewport) (457.68 KB, image/png)
2023-04-23 23:31 PDT, Johannes Odland
no flags Details
Viewport unit test in Facebook IAB (large viewport) (482.42 KB, image/png)
2023-04-23 23:31 PDT, Johannes Odland
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Odland 2023-04-23 23:31:04 PDT
Created attachment 466060 [details]
Viewport unit test in Facebook IAB (small viewport)

A common issue in In App Browsers (IABs) is that the viewport units is incorrectly sized. 
One issue seems to be caused by SFSafariViewController having setting the wrong sizes, this is reported here: https://bugs.webkit.org/show_bug.cgi?id=255708

In apps that use WKWebView we have to rely on the app developer setting the sizes correctly. 
The sizes can be set using `setMinimumViewportInset(_:maximumViewportInset:)`: https://developer.apple.com/documentation/webkit/wkwebview/3974127-setminimumviewportinset


Unfortunately, many apps doesn't set the viewport insets for their IABs. 
One example is the Facebook app, where 100vh, 100svh, 100lvh and 100dvh are all updated to be the same height as the current viewport heigh. (They all act as 100dvh).

As these apps have a large user base, these IABs are a major hurdle in adapting the new viewport units. 
It's necessary to build fallbacks for these IABs specifically. 
As 100vh is dynamically sized, they cause reflow when the user is changing scrolling directions. 

Could setting minimum and maximum viewport sizes be enforced?
Comment 1 Johannes Odland 2023-04-23 23:31:35 PDT
Created attachment 466061 [details]
Viewport unit test in Facebook IAB (large viewport)
Comment 2 Johannes Odland 2023-04-23 23:38:27 PDT
Another example of an app where the viewport units end up wrong is the Firefox app: 

https://github.com/mozilla-mobile/firefox-ios/issues/11574
https://github.com/mozilla-mobile/firefox-ios/issues/8819
Comment 3 Radar WebKit Bug Importer 2023-04-25 19:06:04 PDT
<rdar://problem/108536643>