Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 2876fe9c22e0f13d2cbd960a781737f77862f4a1
https://github.com/WebKit/WebKit/commit/2876fe9c22e0f13d2cbd960a781737f77862f4a1
Author: Antoine Quint <[email protected]>
Date: 2025-12-23 (Tue, 23 Dec 2025)
Changed paths:
M
Source/WebKit/UIProcess/RemoteLayerTree/ios/RemoteLayerTreeDrawingAreaProxyIOS.h
M
Source/WebKit/UIProcess/RemoteLayerTree/ios/RemoteLayerTreeDrawingAreaProxyIOS.mm
Log Message:
-----------
[threaded-animations] Threaded time-based animations should opt into a higher
frame rate on iOS
https://bugs.webkit.org/show_bug.cgi?id=304358
rdar://166731485
Reviewed by Simon Fraser.
On iOS, the `CADisplayLink` that schedules display refresh callbacks that will
trigger page rendering
updates as well as monotonic animation updates is owned by
`RemoteLayerTreeDrawingAreaProxyIOS`. That
display link only ever opts into a higher frame rate than the default 60fps if
"Prefer Page Rendering
Updates near 60fps" is disabled, whereas it's enabled by default.
This means that threaded time-based animations only ever run at 120Hz on Pro
Motion displays if that
flag is disabled. Meanwhile, in the legacy code path, the CA animations we
create opt into a higher
frame rate.
In order to retain high frame rate animations with threaded time-based
animations, we now account for
whether `scheduleDisplayRefreshCallbacksForMonotonicAnimations()` has been
called. However, to ensure
that we do not trigger page rendering updates at a higher frame rate if "Prefer
Page Rendering Updates
near 60fps" is disabled (again, its default value), we now use `DisplayUpdate`
to only call
`RemoteLayerTreeDrawingAreaProxy::didRefreshDisplay()` on frames that match the
expected frame rate for
such updates.
To make the code a bit clearer and modular, we've also refactored the
scheduling and pausing of callbacks
to two new methods: `scheduleDisplayLinkAndSetFrameRate()` and
`pauseDisplayLinkIfNeeded()`. Both account
for the type of callbacks currently scheduled (page rendering and animation
updates) as well as accounting
for "Prefer Page Rendering Updates near 60fps" setting and the preferred frames
per second set by the Web
process, which may be lower than 60fps for low-power mode.
Manual testing included:
1. a page continuously scheduling page rendering updates with
`requestAnimationFrame()` is getting callbacks
at 60fps with "Prefer Page Rendering Updates near 60fps" enabled and at
120fps with "Prefer Page
Rendering Updates near 60fps" disabled.
2. a page continuously scheduling page rendering updates with
`requestAnimationFrame()` is getting callbacks
at 60fps while a threaded time-based animation was getting updates at 120fps
if "Prefer Page Rendering
Updates near 60fps" was enabled, and at 120fps with "Prefer Page Rendering
Updates near 60fps" disabled.
In both cases, low-power mode was also enabled to verify that callbacks ran at
around 30fps and that threaded
monotonic animations were also updated around 30fps. An earlier version of this
patch which failed to account
for the preferred frames per second set for low-power mode had regressed a
couple of tests which proved valuable
to verify the correct behavior:
-
fast/animation/request-animation-frame-throttling-aggressiveThermalMitigation.html
- fast/animation/request-animation-frame-throttling-lowPowerMode.html
*
Source/WebKit/UIProcess/RemoteLayerTree/ios/RemoteLayerTreeDrawingAreaProxyIOS.h:
*
Source/WebKit/UIProcess/RemoteLayerTree/ios/RemoteLayerTreeDrawingAreaProxyIOS.mm:
(-[WKDisplayLinkHandler initWithDrawingAreaProxy:]):
(-[WKDisplayLinkHandler displayLinkFired:]):
(-[WKDisplayLinkHandler timerFired]):
(-[WKDisplayLinkHandler setPreferredFramesPerSecond:]):
(-[WKDisplayLinkHandler setWantsHighFrameRate:]):
(-[WKDisplayLinkHandler updateFrameRate]):
(-[WKDisplayLinkHandler isDisplayRefreshRelevantForPreferredUpdateFrequency]):
(WebKit::RemoteLayerTreeDrawingAreaProxyIOS::didRefreshDisplay):
(WebKit::RemoteLayerTreeDrawingAreaProxyIOS::scheduleDisplayRefreshCallbacks):
(WebKit::RemoteLayerTreeDrawingAreaProxyIOS::pauseDisplayRefreshCallbacks):
(WebKit::RemoteLayerTreeDrawingAreaProxyIOS::scheduleDisplayRefreshCallbacksForMonotonicAnimations):
(WebKit::RemoteLayerTreeDrawingAreaProxyIOS::pauseDisplayRefreshCallbacksForMonotonicAnimations):
(WebKit::RemoteLayerTreeDrawingAreaProxyIOS::scheduleDisplayLinkAndSetFrameRate):
(WebKit::RemoteLayerTreeDrawingAreaProxyIOS::pauseDisplayLinkIfNeeded):
Canonical link: https://commits.webkit.org/304907@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications