Skip to content

Commit

Permalink
Retain an AnimationClock per-document instead of per-page
Browse files Browse the repository at this point in the history
Since each document coarsens timestamps differently, having a clock
for each makes more sense than having one per the all page and then
coarsening when retrieving the time.

Coarsening on the getter was causing a performance regression, so
coarsening at the start of the frame when setting the clock fixes it,
but requires a separate clock per document.

We still keep the page clock for things like SVG images and intersection
stability, though that can be removed in the future.

This also matches the spec more closely, where time is coarsened
when updating the rendering rather than in DocumentTimeline.currentTime.

Bug: 1496136
Change-Id: Ifbd4ca03471232598585db9ee38208c00bcead99
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4981913
Reviewed-by: Robert Flack <[email protected]>
Commit-Queue: Noam Rosenthal <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1217900}
  • Loading branch information
noamr authored and chromium-wpt-export-bot committed Oct 31, 2023
1 parent 89e44c7 commit f3f612a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions hr-time/raf-coarsened-time.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@
for (let i = 0; i < 32; ++i) {
const timestamp = await new Promise(resolve => requestAnimationFrame(ts => resolve(ts)));
const coarse_timestamp = Math.round(timestamp / COARSE_RESOLUTION) * COARSE_RESOLUTION;
assert_approx_equals(timestamp, coarse_timestamp, FLOATING_POINT_ERROR_EPSILON);
assert_approx_equals(timestamp, document.timeline.currentTime, FLOATING_POINT_ERROR_EPSILON);
assert_approx_equals(timestamp, coarse_timestamp, FLOATING_POINT_ERROR_EPSILON,
"timestamp should be coarsened");
assert_approx_equals(timestamp, document.timeline.currentTime, FLOATING_POINT_ERROR_EPSILON,
"document.timeline.currentTimeline should be the same as the rAF callback");
assert_approx_equals(customTimeline.currentTime + CUSTOM_TIMELINE_DELTA,
timestamp, FLOATING_POINT_ERROR_EPSILON);
timestamp, FLOATING_POINT_ERROR_EPSILON,
"originTime for custom timeline should not be coarsened");
}
});
</script>
Expand Down

0 comments on commit f3f612a

Please sign in to comment.