Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Commit 3eecf8c

Browse files
ogerchikovchromium-wpt-export-bot
authored andcommitted
Composited Worklet Animations: Fixed updating local time on main thread.
This CL changes how local time of composited worklet animations is updated on main thread: instead of polling local time on main thread, the local time is posted via animation events by the composited thread to the main thread. Design document: https://docs.google.com/document/d/1vUxaKBLDHQv9ACJUQJH4RXjuQTlWIsSiAFYkMrjccyc/edit?usp=sharing Changes made: - Expanded AnimationEvent to support worklet animation time update event type. - Reused existing mechanism of posting animation events to the main thread to support new event type. - Removed "peek" logic. - Enabled tests that previously failed. Bug: 943787 Change-Id: I2d285506739ea623e292927d21e54910fb7e24bd Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1826872 Reviewed-by: Majid Valipour <[email protected]> Reviewed-by: Robert Flack <[email protected]> Commit-Queue: Olga Gerchikov <[email protected]> Cr-Commit-Position: refs/heads/master@{#706078}
1 parent 72f59ef commit 3eecf8c

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

animation-worklet/inactive-timeline.https.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@
4949
promise_test(async t => {
5050
const animation = createScrollLinkedWorkletAnimation(t);
5151
const scroller = animation.timeline.scrollSource;
52+
const target = animation.effect.target;
53+
54+
// There is no direct way to control when local times of composited
55+
// animations are synced to the main thread. This test uses another
56+
// composited worklet animation with an always active timeline as an
57+
// indicator of when the sync is ready. The sync is done when animation
58+
// effect's output has changed as a result of advancing the timeline.
59+
const animationRef = createScrollLinkedWorkletAnimation(t);
60+
const scrollerRef = animationRef.timeline.scrollSource;
61+
const targetRef = animationRef.effect.target;
5262

5363
const maxScroll = scroller.scrollHeight - scroller.clientHeight;
5464
const timeRange = animation.timeline.timeRange;
@@ -60,6 +70,7 @@
6070
scroller.scrollTop;
6171

6272
animation.play();
73+
animationRef.play();
6374
assert_equals(animation.currentTime, null,
6475
'Initial current time must be unresolved in idle state.');
6576
assert_equals(animation.startTime, null,
@@ -72,6 +83,17 @@
7283
assert_equals(animation.startTime, null,
7384
'Initial start time must be unresolved in playing state.');
7485

86+
scrollerRef.scrollTop = 0.2 * maxScroll;
87+
88+
// Wait until local times are synced back to the main thread.
89+
await waitForAnimationFrameWithCondition(_ => {
90+
return animationRef.effect.getComputedTiming().localTime == 200;
91+
});
92+
93+
assert_equals(animation.effect.getComputedTiming().localTime, null,
94+
'The underlying effect local time must be undefined while the ' +
95+
'timeline is inactive.');
96+
7597
// Make the timeline active.
7698
scroller.style.display = ""
7799
scroller.scrollTop;
@@ -81,6 +103,15 @@
81103
assert_times_equal(animation.startTime, 0,
82104
'Start time must be initialized.');
83105

106+
scrollerRef.scrollTop = 0.4 * maxScroll;
107+
// Wait until local times are synced back to the main thread.
108+
await waitForAnimationFrameWithCondition(_ => {
109+
return animationRef.effect.getComputedTiming().localTime == 400;
110+
});
111+
assert_times_equal(animation.effect.getComputedTiming().localTime, 200,
112+
'When the timeline becomes newly active, the underlying effect\'s ' +
113+
'timing should be properly updated.');
114+
84115
// Make the timeline inactive again.
85116
scroller.style.display = "none"
86117
scroller.scrollTop;
@@ -90,6 +121,16 @@
90121
assert_equals(animation.startTime, null,
91122
'Initial start time must be unresolved.');
92123

124+
scrollerRef.scrollTop = 0.6 * maxScroll;
125+
scrollerRef.scrollTop;
126+
// Wait until local times are synced back to the main thread.
127+
await waitForAnimationFrameWithCondition(_ => {
128+
return animationRef.effect.getComputedTiming().localTime == 600;
129+
});
130+
131+
assert_times_equal(animation.effect.getComputedTiming().localTime, 200,
132+
'When the timeline becomes newly inactive, the underlying effect\'s ' +
133+
'timing should stay unchanged.');
93134
}, 'When timeline time becomes inactive previous current time must be ' +
94135
'the current time and start time unresolved');
95136
done();

0 commit comments

Comments
 (0)