Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 3ef0f816b871dce775eb312f998f2de34fb4e4af
https://github.com/WebKit/WebKit/commit/3ef0f816b871dce775eb312f998f2de34fb4e4af
Author: Antoine Quint <[email protected]>
Date: 2026-09-10 (Thu, 10 Sep 2026)
Changed paths:
A PerformanceTests/Animation/scroll-timeline-shared-name.html
A PerformanceTests/Animation/scroll-timeline-unique-names.html
M Source/WebCore/animation/StyleOriginatedTimelinesController.cpp
M Source/WebCore/animation/StyleOriginatedTimelinesController.h
Log Message:
-----------
[scroll-animations] Style resolution with scroll-timeline name blocks main
thread for multiple seconds
https://bugs.webkit.org/show_bug.cgi?id=322283
rdar://186090970
Reviewed by Anne van Kesteren.
When N elements have the same `scroll-timeline-name` and N animation targets
use it as their
`animation-timeline`, the time taken to resolve style would grow cubically
because we run three
nested linear passes under
`StyleOriginatedTimelinesController::determineTimelineForElement()`:
1. each element declaring the name registers a timeline,
2. each registration re-syncs every animation already using that name, and
3. each of those re-syncs scans every timeline registered under that name.
To ensure that the time taken to resolve style in such cases is linear we:
1. no longer re-sync animations when registering or unregistering a named
timeline, instead adding
them to a list of timelines to update in one pass under style resolution (in
`documentDidResolveStyle()`)
the same way we already batch animation attachment requests.
2. partition timelines into those declared within the animation target's
hierarchy and those outside,
processing timelines inside the target's hierarchy, the more common case, first
and only timelines
matching globally as a backup.
As a result, the new performance test
`Animation/scroll-timeline-shared-name.html` that used to run
on a MacBook Pro (M4 Max) for ~360ms now takes ~12ms.
This patch was created using LLM code assistance.
* PerformanceTests/Animation/scroll-timeline-shared-name.html: Added.
* PerformanceTests/Animation/scroll-timeline-unique-names.html: Added.
* Source/WebCore/animation/StyleOriginatedTimelinesController.cpp:
(WebCore::StyleOriginatedTimelinesController::determineTimelineForElement):
(WebCore::StyleOriginatedTimelinesController::registerNamedScrollTimeline):
(WebCore::StyleOriginatedTimelinesController::documentDidResolveStyle):
(WebCore::StyleOriginatedTimelinesController::registerNamedViewTimeline):
(WebCore::StyleOriginatedTimelinesController::unregisterNamedTimeline):
(WebCore::StyleOriginatedTimelinesController::updateNamedTimelineMapForTimelineScope):
(WebCore::StyleOriginatedTimelinesController::styleableWasRemoved):
(WebCore::timelineIsInScopeForTarget): Deleted.
* Source/WebCore/animation/StyleOriginatedTimelinesController.h:
Canonical link: https://commits.webkit.org/320902@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications