Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 31492bb45dd5ad9f568d0635bf1d55c52c5d7201
      
https://github.com/WebKit/WebKit/commit/31492bb45dd5ad9f568d0635bf1d55c52c5d7201
  Author: Simon Fraser <[email protected]>
  Date:   2026-05-16 (Sat, 16 May 2026)

  Changed paths:
    M 
Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteLayerTreeEventDispatcher.h
    M 
Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteLayerTreeEventDispatcher.mm

  Log Message:
  -----------
  Safari can hang under RemoteScrollingCoordinatorProxyMac::displayDidRefresh() 
sometimes
https://bugs.webkit.org/show_bug.cgi?id=314928
rdar://173029654

Reviewed by Abrar Rahman Protyasha.

`RemoteLayerTreeEventDispatcher::mainThreadDisplayDidRefresh()` bounces to the
scrolling thread in order to set state that allows us to detect when the main
thread commit is taking too long, letting the scrolling thread go ahead with a
commit to keep scrolling smooth.

Threaded animations recently added a condition to
`scrollingTreeWasRecentlyActive()`, causing this path to be taken more often
(usually it would bail early if there were no recent wheel events). That 
resulting
in a pattern where the second and subsequent calls to
`mainThreadDisplayDidRefresh()` would get blocked for however long the condition
in `waitForRenderingUpdateCompletionOrTimeout()` would take to time out (about
half a frame—9ms) because the previous wait would delay the 
`semaphore.signal()`.
So with a flood of `mainThreadDisplayDidRefresh` on the main thread, each would
delay for 9ms, causing a hang.

Fix by splitting out `scrollingTreeWasRecentlyActive()` and
`scrollingThreadNeedsDisplayDidRefresh()`; only the latter needs to check for
threaded animations; it's just called from `displayDidRefresh()`.

In addition, if the state is `SynchronizationState::Desynchronized`, there's no
point in `RemoteLayerTreeEventDispatcher::mainThreadDisplayDidRefresh()` waiting
anyway. This can happen when a `displayDidRefresh` does not result in a layer 
tree
commit coming back from the web process, which occurs when `CommitDelayState` is
`Delayed`.

* Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteLayerTreeEventDispatcher.h:
* Source/WebKit/UIProcess/RemoteLayerTree/mac/RemoteLayerTreeEventDispatcher.mm:
(WebKit::RemoteLayerTreeEventDispatcher::scrollingThreadNeedsDisplayDidRefresh):
(WebKit::RemoteLayerTreeEventDispatcher::scrollingTreeWasRecentlyActive):
(WebKit::RemoteLayerTreeEventDispatcher::haveLayersWithAnimations):
(WebKit::RemoteLayerTreeEventDispatcher::mainThreadDisplayDidRefresh):

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to