mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
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:
parent
46256b33ef
commit
92061132f3
5 changed files with 37 additions and 15 deletions
|
@ -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 app_units::Au;
|
||||
use compositor_layer::{CompositorData, CompositorLayer, RcCompositorLayer, WantsScrollEventsFlag};
|
||||
|
@ -1550,7 +1551,13 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
|
||||
fn tick_animations_for_pipeline(&mut self, pipeline_id: PipelineId) {
|
||||
self.schedule_delayed_composite_if_necessary();
|
||||
self.constellation_chan.send(ConstellationMsg::TickAnimation(pipeline_id)).unwrap()
|
||||
let animation_callbacks_running = self.pipeline_details(pipeline_id).animation_callbacks_running;
|
||||
let animation_type = if animation_callbacks_running {
|
||||
AnimationTickType::Script
|
||||
} else {
|
||||
AnimationTickType::Layout
|
||||
};
|
||||
self.constellation_chan.send(ConstellationMsg::TickAnimation(pipeline_id, animation_type)).unwrap()
|
||||
}
|
||||
|
||||
fn constrain_viewport(&mut self, pipeline_id: PipelineId, constraints: ViewportConstraints) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue