[webkit-changes] [WebKit/WebKit] 07b064: [iOS] Page sometimes flashes white after exiting e...

Aditya Keerthi noreply at github.com
Fri May 12 14:11:22 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 07b06490caa2089f50c5811b87051b5d65dadf81
      https://github.com/WebKit/WebKit/commit/07b06490caa2089f50c5811b87051b5d65dadf81
  Author: Aditya Keerthi <akeerthi at apple.com>
  Date:   2023-05-12 (Fri, 12 May 2023)

  Changed paths:
    M Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm

  Log Message:
  -----------
  [iOS] Page sometimes flashes white after exiting element fullscreen
https://bugs.webkit.org/show_bug.cgi?id=256662
rdar://104149279

Reviewed by Tim Horton.

While performing an "animated resize", geometry updates are deferred until the
resize has completed. This ensures that the Web process does not receive any
visible content rect updates during resize. The geometry update is then
triggered once the resize is complete.

However, it is also possible for visible content rect updates to be sent
outside of the normal scheduling flow, through
`WebPageProxy::resendLastVisibleContentRects`. The last visible content rect
update is resent when attempting to perform a programmatic scroll that does not
change modify the scroll view's position. This logic was added in 152880 at main,
to ensure the Web process state was not out-of-sync with the UI process state.

When exiting element fullscreen, both an "animated resize" and programmatic
scroll are performed. The purpose of the scroll is to restore the web view's
original scroll position prior to entering fullscreen. Once the resize is
complete, a geometry update is scheduled (asynchronously). Then, the Web process
notifies the UI process that a scroll needs to occur. If the scroll does not
end up modifying the scroll view's position, the last visible content rect
update, which still contains the fullscreen viewport information, is resent.
Finally, the scheduled geometry update (with the correct viewport information) is
sent.

Consequently, exiting fullscreen can result in two successive visible
content rect updates, the first of which is incorrect. Flashing is observed as
a result of temporarily incorrect viewport information.

To fix, suppress resending visible content rect updates during the period of
time where geometry updates have stopped being deferred, but the scheduled
update is still pending. This ensures that spurious viewport information is not
send to the Web process, removing a source of flashing.

* Source/WebKit/UIProcess/API/ios/WKWebViewIOS.mm:
(-[WKWebView _scrollToContentScrollPosition:scrollOrigin:animated:]):

Consult `didDeferUpdateVisibleContentRectsForAnyReason` to identify the period
of time described above. This is safe to do, since a geometry update will
eventually occur once deferral has ended. Furthermore, the bit is reset once the
next update is dispatched.

* Tools/TestWebKitAPI/Tests/WebKitCocoa/AnimatedResize.mm:
(TEST):

Add a API test to exercise the codepaths that result in incorrect viewport
information being sent to the Web process. Without this fix, the test fails
as the window's `innerWidth`/`innerHeight` is observed to be size prior to
resizing, even though the resize is complete.

Canonical link: https://commits.webkit.org/264024@main




More information about the webkit-changes mailing list