Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: a7c6f460405d1f46302335064b8ae51f27659220
https://github.com/WebKit/WebKit/commit/a7c6f460405d1f46302335064b8ae51f27659220
Author: Anne van Kesteren <[email protected]>
Date: 2026-05-13 (Wed, 13 May 2026)
Changed paths:
M LayoutTests/TestExpectations
M
LayoutTests/imported/w3c/web-platform-tests/hr-time/raf-coarsened-time.https-expected.txt
M Source/WTF/WTF.xcodeproj/project.pbxproj
M Source/WTF/wtf/CMakeLists.txt
M Source/WTF/wtf/Forward.h
A Source/WTF/wtf/ReducedResolutionSeconds.h
M Source/WTF/wtf/text/TextStream.cpp
M Source/WTF/wtf/text/TextStream.h
M Source/WebCore/Headers.cmake
M Source/WebCore/WebCore.xcodeproj/project.pbxproj
M Source/WebCore/animation/AnimationTimelinesController.cpp
M Source/WebCore/animation/AnimationTimelinesController.h
M Source/WebCore/animation/FrameRateAligner.cpp
M Source/WebCore/animation/FrameRateAligner.h
M Source/WebCore/dom/ScriptedAnimationController.cpp
M Source/WebCore/dom/ScriptedAnimationController.h
M Source/WebCore/html/HTMLMediaElement.h
M Source/WebCore/html/HTMLVideoElement.cpp
M Source/WebCore/html/HTMLVideoElement.h
M Source/WebCore/page/IntersectionObserver.h
M Source/WebCore/page/LocalDOMWindow.cpp
M Source/WebCore/page/LocalDOMWindow.h
M Source/WebCore/page/Performance.cpp
M Source/WebCore/page/Performance.h
R Source/WebCore/page/ReducedResolutionSeconds.h
Log Message:
-----------
requestAnimationFrame() has no sub-millisecond precision when
cross-origin-isolated
https://bugs.webkit.org/show_bug.cgi?id=314531
Reviewed by Ryosuke Niwa.
ScriptedAnimationController::serviceRequestAnimationFrameCallbacks() has been
rounding the callback timestamp to whole milliseconds via
std::round(1000 * timestamp.seconds()) since 224063@main — an unreviewed
follow-up two days after 223937@main, which had originally switched the
computation to timestamp.milliseconds() as part of the migration to Seconds.
The follow-up was described as a stopgap for floating-point jitter while
Seconds::roundedMilliseconds() was being landed; that method never arrived
and the rounding has been in place ever since.
In a cross-origin-isolated context Performance::timePrecision is 20μs
rather than 1ms, so the input ReducedResolutionSeconds already carries real
sub-millisecond information. Rounding it to integer milliseconds throws
that away, causing the rAF timestamp to disagree with
document.timeline.currentTime.
The fix is structural rather than targeted. ReducedResolutionSeconds was
a typedef of Seconds, which let every API exposing a DOMHighResTimeStamp
derived from reduceTimeResolution's output pick its own conversion formula.
Those formulas disagree at ~1 ulp for values that aren't exactly
representable in seconds-double, so two APIs computing from the same frozen
timestamp could produce DOMHighResTimeStamps that drift relative to each
other, and in pathological cases appear to go backwards.
Promote ReducedResolutionSeconds to a proper class in wtf/, modeled on
MonotonicTime and WallTime via GenericTimeMixin. Its seconds(),
milliseconds(), and microseconds() accessors round at microsecond
precision, so every API threaded through this type observes the same value
regardless of the conversion path. This subsumes the microsecond-rounding
idiom that was repeated inline in secondsToWebAnimationsAPITime.
The fix does not extend to every API that exposes a reduceTimeResolution-derived
DOMHighResTimeStamp: event-timing candidates are stored in Seconds-typed struct
fields, AnimationTimelinesController's current-time cache is a
Markable<Seconds>,
and so on. Those sites decay a ReducedResolutionSeconds back to a raw Seconds
and lose the rounding, which is the same class of bug. This patch leaves them
observable but explicit: the only way to get a raw Seconds out of a
ReducedResolutionSeconds is deprecatedNonRoundedSeconds(), chosen to be long
and greppable so each remaining call site is visible as a follow-up bug to
fix. GenericTimeMixin's base secondsSinceEpoch() is hidden so the boundary
cannot be crossed accidentally.
Covered by
imported/w3c/web-platform-tests/hr-time/raf-coarsened-time.https.html.
Canonical link: https://commits.webkit.org/313153@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications