diff options
author | yvt <i@yvt.jp> | 2022-10-28 12:49:47 +0900 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2023-02-10 12:42:51 +0100 |
commit | af1b0b0f14d951b8e712b71a220e308d7b2f0c2e (patch) | |
tree | 982f5f829d585c553700ff6deb36b678efc4f396 /components/script/script_thread.rs | |
parent | aa2e1433d28158eb06e6a8a9b09b551437c4b55f (diff) | |
download | servo-af1b0b0f14d951b8e712b71a220e308d7b2f0c2e.tar.gz servo-af1b0b0f14d951b8e712b71a220e308d7b2f0c2e.zip |
fix(script): update animation timeline before processing pending events
This commit reverses the order of the `send_pending_events` and
`update_animation_timeline` calls in `ScriptThread::update_animations_
send_events` so that animation-related events pended by the latter are
processed by the former.
The new calling order is more compliant with the "update animations and
send events" algorithm steps from [the Web Animations specification][1].
The old implementation was prone to blocking for an indefinite period
while holding pending events. Due to complex interaction with other
events and timing behavior, I was only able to reproduce the problem
under the following conditions:
- *The `maybe_observe_paint_time` call in `LayoutThread::compute_abs_
pos_and_build_display_list` is removed from the code*. While
performance events may seem irrelevant to the issue, they would
bombard the script thread with events. *Any* extra messages received
would unblock the event loop and prevent the manifestation of the
issue. (But, of course, we aren't supposed to count on that to avoid
the issue.)
- Servo is running in a headless mode, which somehow makes it less
likely for the script thread to receive a `TickAllAnimations` event
after sending `AnimationState::NoAnimationsPresent`.
With the above conditions met and the stars aligned, you can reproduce
the problem by running the WPT test `/css/css-transitions/events-001.
html`.
[1]: https://drafts.csswg.org/web-animations-1/#update-animations-and-send-events
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r-- | components/script/script_thread.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 506cd5d6bf2..a82edd61cc3 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1705,11 +1705,11 @@ impl ScriptThread { // Perform step 11.10 from https://html.spec.whatwg.org/multipage/#event-loops. fn update_animations_and_send_events(&self) { for (_, document) in self.documents.borrow().iter() { - document.animations().send_pending_events(); + document.update_animation_timeline(); } for (_, document) in self.documents.borrow().iter() { - document.update_animation_timeline(); + document.animations().send_pending_events(); } } |