Fix animation smoothness when using requestAnimationFrame.

Previously, the flow for ticking animations was:

Compositor -> Constellation -> Layout -> Script

However, this means that the compositor <-> layout messages can thrash, meaning layout thread is very rarely idle.

This means that the script thread (which joins on the layout thread during reflow) was unable to execute and run rAF callbacks.

With this change, the flow is now:

Compositor -> Constellation -> Script (when rAF is active).
Compositor -> Constellation -> Layout (when transitions / animations are active and no rAF is present).

This makes rAF based animation *much* smoother.
This commit is contained in:
Glenn Watson 2016-03-04 06:18:34 +10:00
parent 46256b33ef
commit 92061132f3
5 changed files with 37 additions and 15 deletions

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use AnimationTickType;
use CompositorMsg as ConstellationMsg;
use compositor_thread::{CompositorEventListener, CompositorReceiver};
use compositor_thread::{InitialCompositorState, Msg};
@ -98,7 +99,7 @@ impl CompositorEventListener for NullCompositor {
AnimationState::NoAnimationsPresent |
AnimationState::NoAnimationCallbacksPresent => {}
AnimationState::AnimationCallbacksPresent => {
let msg = ConstellationMsg::TickAnimation(pipeline_id);
let msg = ConstellationMsg::TickAnimation(pipeline_id, AnimationTickType::Script);
self.constellation_chan.send(msg).unwrap()
}
}