Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compositing: Stop compositing unnecessarily after each animation frame. #9663

Merged
merged 1 commit into from Feb 24, 2016

Commits on Feb 24, 2016

  1. compositing: Stop compositing unnecessarily after each animation frame.

    Instead, schedule a delayed composite after each frame of an animation.
    
    The previous code would cause jank, because the following sequence
    frequently occurred:
    
    1. The page uses `requestAnimationFrame()` to request a frame.
    
    2. The compositor receives the message, schedules a composite,
    dispatches the rAF message to the script thread, composites, and goes to
    sleep waiting for vblank (frame 1).
    
    3. The script makes a change and sends it through the pipeline.
    Eventually it gets painted and is sent to the compositor, but the
    compositor is sleeping.
    
    4. The compositor wakes up, sees the new painted content, page flips,
    and goes to sleep (frame 2). Repeat from step 1.
    
    The problem is that we have two composition frames, not just one. This
    halves Web apps' framerate!
    
    This commit fixes the problem by scheduling the composite in step 2 to
    12 ms in the future. We already have this delayed-composition
    functionality in the form of the scrolling timer, which I repurposed and
    renamed to the "delayed composition timer" for this task. This change
    gives the page 12 ms to prepare the frame, which seems to usually be
    enough, especially with WebRender.
    
    Note that simply removing the scheduled composite after rAF is not the
    correct solution. If this is done, then pages that call rAF and don't
    modify the page won't receive future rAFs, since the compositor will be
    sleeping and won't be notified of vblank.
    
    Fixes a bunch of jank in browser.html. The remaining jank seems to be a
    problem with browser.html itself.
    pcwalton committed Feb 24, 2016
You can’t perform that action at this time.