diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2016-02-16 11:01:23 -0800 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2016-02-24 14:06:46 -0800 |
commit | 9b4cc416954ac550788f3cd82f0016d74d4995ea (patch) | |
tree | c6280ecb54f8007f78e1ee79f298106beed34e60 /components/layout/layout_thread.rs | |
parent | 09e987b559688caeef75aecd265c68f8d2b5c7e2 (diff) | |
download | servo-9b4cc416954ac550788f3cd82f0016d74d4995ea.tar.gz servo-9b4cc416954ac550788f3cd82f0016d74d4995ea.zip |
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.
Diffstat (limited to 'components/layout/layout_thread.rs')
-rw-r--r-- | components/layout/layout_thread.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/components/layout/layout_thread.rs b/components/layout/layout_thread.rs index e1e163acb39..b35043eb087 100644 --- a/components/layout/layout_thread.rs +++ b/components/layout/layout_thread.rs @@ -1208,8 +1208,8 @@ impl LayoutThread { self.tick_animations(&mut rw_data); self.script_chan - .send(ConstellationControlMsg::TickAllAnimations(self.id)) - .unwrap(); + .send(ConstellationControlMsg::TickAllAnimations(self.id)) + .unwrap(); } pub fn tick_animations(&mut self, rw_data: &mut LayoutThreadData) { |