Skip to content

Fix Running Animation Frame Callbacks #33251

@gterzian

Description

@gterzian

When receiving this message

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.

pub fn tick_all_animations(&self) {

The spec requires rafs to be called in a given order, which is tested at

<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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions