[webkit-changes] [WebKit/WebKit] e74aa7: [UI-side compositing] tiled-drawing/tiled-backing-...

Wenson Hsieh noreply at github.com
Fri Mar 24 11:38:59 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e74aa7f36cbd532f681b2c015002264a7d756b52
      https://github.com/WebKit/WebKit/commit/e74aa7f36cbd532f681b2c015002264a7d756b52
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2023-03-24 (Fri, 24 Mar 2023)

  Changed paths:
    M LayoutTests/tiled-drawing/tiled-backing-in-window.html
    M Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm

  Log Message:
  -----------
  [UI-side compositing] tiled-drawing/tiled-backing-in-window.html fails when run on a 2x display
https://bugs.webkit.org/show_bug.cgi?id=254387
rdar://107038034

Reviewed by Simon Fraser.

This test fails when UI-side compositing is enabled. Consider the following sequence of events,
immediately upon unparenting the web view via `UIScriptController`, when running the test on a 2x
display with GPUP and UI-side compositing enabled:

1.  In the UI process, we schedule an activity state change (to tell the web process that the view
    is no longer in a window).

2.  At the same time, we send an IPC message `WebPage::SetDeviceScaleFactor(2.0)` (the intrinsic
    device scale is 2.0 in the UI process after unparenting the web view, since we fall back to the
    main `NSScreen`'s `-backingScaleFactor`).

3.  In the web process, we receive the new device scale of 2.0, and mark each graphics layer with a
    dirty bit: `LayerChange::ContentsScaleChanged`.

4.  In the web process, we then perform a rendering update that was previously scheduled (for any
    reason). This causes us to `flushCompositingState` on the root layer, and recursively apply the
    new contents scale to all sublayers.

5.  In the UI process, we then (finally) dispatch the activity state change that was scheduled in
    step (1).

6.  In the web process, we receive the new activity state, and detach the root layer underneath
    `RenderLayerCompositor::setIsInWindow`, with `isInWindow := false`.

Thus, each `PlatformCALayerRemote` ends up with a scale of 2.0 instead of 1.0 after unparenting the
web view, which is reflected in the output of `layerTreeAsText`. In contrast, when GPUP and UI-side
compositing are disabled, step (4) occurs after (5-6) above, which causes us to bail earlier before
flushing the new backing store scale to the layer tree:

```
void RenderLayerCompositor::flushPendingLayerChanges(bool isFlushRoot)
{
…
    if (rootLayerAttachment() == RootLayerUnattached) {
        m_shouldFlushOnReattach = true;
        return;      // <---------------- We early return here in the non-GPUP case.
    }
…
```

...which allows the layers to retain a device scale of 1. Due to the fact that it's unclear whether
the post-GPUP behavior is better or worse (as the old behavior effectively leaves the layer content
scales out of sync with the device scale factor in the UI process), it's probably best to just fix
this test by making the test itself by forcing a `deviceScaleFactor` of 1.0.

* LayoutTests/tiled-drawing/tiled-backing-in-window.html:
* Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm:
(WTR::PlatformWebView::changeWindowScaleIfNeeded):

Ensure that we actually call into `-_setOverrideDeviceScaleFactor:` when specifying a
`deviceScaleFactor=1.0` test runner option, by adjusting the implementation of this helper method
to not early return from the entire function if only the window's `-backingScaleFactor` matches.

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




More information about the webkit-changes mailing list