Bug 228115 - WKWebView contents is offset at startup (top inset)
Summary: WKWebView contents is offset at startup (top inset)
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: Safari 14
Hardware: Mac (Intel) macOS 11
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2021-07-20 11:36 PDT by gmorin
Modified: 2021-07-22 18:39 PDT (History)
8 users (show)

See Also:


Attachments
Two sample projects (92.18 KB, application/zip)
2021-07-20 11:36 PDT, gmorin
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description gmorin 2021-07-20 11:36:50 PDT
Created attachment 433886 [details]
Two sample projects

On app startup, contents loaded in a WKWebView is offset vertically. We’ve found that this behavior only occurs when the following conditions are met:
- The window containing the webview is configured to use a Full Size Content View
- The window's title bar is not transparent

We provide two sample applications which allow reproduction of the bug.
- The first one shows the most basic way to reproduce the problem. We could easily use some workarounds to avoid the problem, such as refrain from using safe area guides and adjust the webview’s constraints to prevent the webview from appearing under the toolbar.
- The second one shows a more complex example, with a full height sidebar while the webview appears on the content’s side of the SplitView.

We've found that the problem seems to come from WebViewImpl, where a top inset is set using the following conditionL:
`if ((window.styleMask & NSWindowStyleMaskFullSizeContentView) && !window.titlebarAppearsTransparent && ![m_view enclosingScrollView]) {
    ...
}`

Somewhat curious is the fact that slightly moving or resizing the window redraws the webview correctly and removes the inset...
Comment 1 Smoley 2021-07-22 16:59:14 PDT
Thanks for filing, ccing relevant folks.
Comment 2 Radar WebKit Bug Importer 2021-07-22 16:59:45 PDT
<rdar://problem/80991170>
Comment 3 Tim Horton 2021-07-22 18:39:01 PDT
Would be super interested to know if https://trac.webkit.org/changeset/279708/webkit fixes this.