[webkit-changes] [WebKit/WebKit] b51b20: [UI-side compositing] Flash of flipped content whe...

Wenson Hsieh noreply at github.com
Wed Apr 5 17:59:01 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b51b2033860f0b19c303ae83cb2c0551d066baf5
      https://github.com/WebKit/WebKit/commit/b51b2033860f0b19c303ae83cb2c0551d066baf5
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2023-04-05 (Wed, 05 Apr 2023)

  Changed paths:
    M Source/WebKit/UIProcess/API/Cocoa/_WKThumbnailView.mm
    M Tools/TestWebKitAPI/SourcesCocoa.txt
    M Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
    M Tools/TestWebKitAPI/Tests/WebKit/WKThumbnailView.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/GPUProcess.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/ImageAnalysisTests.mm
    A Tools/TestWebKitAPI/cocoa/CGImagePixelReader.cpp
    A Tools/TestWebKitAPI/cocoa/CGImagePixelReader.h
    A Tools/TestWebKitAPI/cocoa/EnableUISideCompositingScope.h
    A Tools/TestWebKitAPI/cocoa/EnableUISideCompositingScope.mm

  Log Message:
  -----------
  [UI-side compositing] Flash of flipped content when pinching into tab overview in Safari
https://bugs.webkit.org/show_bug.cgi?id=255042
rdar://107499419

Reviewed by Simon Fraser.

Currently, when pinching out to tab overview when UI-side compositing is enabled, there's a brief
flash of partially-flipped page tiles in the `_WKThumbnailView`, as Safari swaps out the contents of
the tab with the web view thumbnail. When this happens, the thumbnail view asynchronously requests a
snapshot from the web page; before the snapshot arrives, however, we reparent the web view's root
layer inside the layer hierarchy of the thumbnail view, to continue displaying live web content.

When UI-side compositing is enabled, however, this reparenting causes page tiles to become flipped
underneath the `_WKThumbnailView`; this is because while `WKWebView` on macOS returns `YES` for
`-isFlipped`, `_WKThumbnailView` does not (all other aspects being equal). Note that when UI-side
compositing is disabled, the hosting layer has `geometryFlipped=true`, which allows us to get the
flipping behavior right.

To fix this, we simply implement `-[_WKThumbnailView isFlipped]` and return `YES`, to align with
`WKWebView`. Note that this is safe to do even when UI-side compositing is disabled, since it's the
only layer underneath `_WKThumbnailView`'s layer anyways, and covers the entire layer (which is how
it works in `WKWebView` as well).

Test: WebKit.WKThumbnailViewLayerReparentingWithUISideCompositing

* Source/WebKit/UIProcess/API/Cocoa/_WKThumbnailView.mm:
(-[_WKThumbnailView isFlipped]):

Return `YES` here to align with `WKWebView` on macOS. See above for more details.

* Tools/TestWebKitAPI/SourcesCocoa.txt:
* Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* Tools/TestWebKitAPI/Tests/WebKit/WKThumbnailView.mm:
(-[NSView _test_cgImage]):

Add a testing helper method to grab a layer snapshot of an `NSView`, and return it as a `CGImage`.

(TestWebKitAPI::TEST):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/GPUProcess.mm:
(-[NSUserDefaults swizzled_objectForKey:]): Deleted.
(TestWebKitAPI::EnableUISideCompositingScope::EnableUISideCompositingScope): Deleted.
(TestWebKitAPI::EnableUISideCompositingScope::~EnableUISideCompositingScope): Deleted.

Move the `CGImagePixelReader` helper class out into a separate file.

* Tools/TestWebKitAPI/Tests/WebKitCocoa/ImageAnalysisTests.mm:
(TestWebKitAPI::CGImagePixelReader::CGImagePixelReader): Deleted.
(TestWebKitAPI::CGImagePixelReader::isTransparentBlack const): Deleted.
(TestWebKitAPI::CGImagePixelReader::at const): Deleted.
(TestWebKitAPI::CGImagePixelReader::width const): Deleted.
(TestWebKitAPI::CGImagePixelReader::height const): Deleted.
* Tools/TestWebKitAPI/cocoa/CGImagePixelReader.cpp: Added.
(TestWebKitAPI::CGImagePixelReader::CGImagePixelReader):
(TestWebKitAPI::CGImagePixelReader::isTransparentBlack const):
(TestWebKitAPI::CGImagePixelReader::at const):
* Tools/TestWebKitAPI/cocoa/CGImagePixelReader.h: Added.
(TestWebKitAPI::CGImagePixelReader::width const):
(TestWebKitAPI::CGImagePixelReader::height const):
* Tools/TestWebKitAPI/cocoa/EnableUISideCompositingScope.h: Added.
* Tools/TestWebKitAPI/cocoa/EnableUISideCompositingScope.mm: Added.

Move the `EnableUISideCompositingScope` helper class out into a separate file.

(-[NSUserDefaults swizzled_objectForKey:]):
(TestWebKitAPI::EnableUISideCompositingScope::EnableUISideCompositingScope):
(TestWebKitAPI::EnableUISideCompositingScope::~EnableUISideCompositingScope):

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




More information about the webkit-changes mailing list