-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Description
When receiving this message
servo/components/script/script_thread.rs
Line 1875 in 46dbe4c
| FromConstellation(ConstellationControlMsg::TickAllAnimations( |
We do two things:
- Note a rendering opp(which queues a task to "update the rendering")
- Note pending animation tick(which stores the tick on the document for later processing in the "update the rendering" task).
When the "update the rendering" task runs, we call into tick_all_animations for all docs, which runs the animation frame callbacks if a tick of type AnimationTickType::REQUEST_ANIMATION_FRAME was previously stored.
servo/components/script/dom/document.rs
Line 3301 in 46dbe4c
| pub fn tick_all_animations(&self) { |
The spec requires rafs to be called in a given order, which is tested at
servo/tests/wpt/tests/html/webappapis/update-rendering/child-document-raf-order.html
Line 4 in cbc9304
| <link rel="help" href="https://html.spec.whatwg.org/multipage/webappapis.html#update-the-rendering"> |
Problem: the compositor sends animation ticks in no specific order, so there is a race condition on the ordering of rafs in the presence of iframes(which is not due to #31973), because when we "note a pending animation tick" for document, and queue the "update the rendering" task, we may not have received all ticks from the compositor by the time the task runs.
That is, I think, why the test above fails intermittently.
When it goes right, we hit the lucky path:
- "note a pending animation tick" for iframe
- "note a pending animation tick" for parent
- Run "update the rendering" task, which first calls the rafs of the parent.
The unlucky one is:
- "note a pending animation tick" for iframe
- Run "update the rendering" task, which only calls the rafs of the iframe.
- "note a pending animation tick" for parent(too late, test fails)
Fix: we need to run rafs for a document as part of "update the rendering" if one was requested, even if no ticks were received from the compositor for that document, so long as we received a tick for any pipeline in that script-thread from the compositor.
Longer term we should consolidate the workflow between script and the compositor so that it is not pipeline-based, but rather "render opportunity" based, the current problem is a sympton of how we would do things before restructuring to match https://html.spec.whatwg.org/multipage/webappapis.html#update-the-rendering). There is a discussion over at https://servo.zulipchat.com/#narrow/stream/263398-general/topic/HTML.20event-loop.20fix