mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
compositor: Tick animations for an entire WebView at once (#36662)
Previously, when processing animations, the compositor would sent a tick message to each pipeline. This is an issue because now the `ScriptThread` always processes rendering updates for all `Document`s in order to ensure properly ordering. This change makes it so that tick messages are sent for an entire WebView. This means that each `ScriptThread` will always receive a single tick for every time that animations are processed, no matter how many frames are animating. This is the first step toward a refresh driver. In addition, we discard the idea of ticking animation only for animations and or only for request animation frame callbacks. The `ScriptThread` can no longer make this distinction due to the specification and the compositor shouldn't either. This should not really change observable behavior, but should make Servo more efficient when more than a single frame in a `ScriptThread` is animting at once. Testing: This is covered by existing WPT tests as it mainly just improve animation efficiency in a particular case. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
3793936f05
commit
cbc363bedd
9 changed files with 134 additions and 172 deletions
|
@ -21,9 +21,7 @@ use base::id::WebViewId;
|
|||
use canvas_traits::canvas::CanvasId;
|
||||
use canvas_traits::webgl::{self, WebGLContextId, WebGLMsg};
|
||||
use chrono::Local;
|
||||
use constellation_traits::{
|
||||
AnimationTickType, NavigationHistoryBehavior, ScriptToConstellationMessage,
|
||||
};
|
||||
use constellation_traits::{NavigationHistoryBehavior, ScriptToConstellationMessage};
|
||||
use content_security_policy::{self as csp, CspList, PolicyDisposition};
|
||||
use cookie::Cookie;
|
||||
use cssparser::match_ignore_ascii_case;
|
||||
|
@ -516,10 +514,6 @@ pub(crate) struct Document {
|
|||
pending_input_events: DomRefCell<Vec<ConstellationInputEvent>>,
|
||||
/// The index of the last mouse move event in the pending compositor events queue.
|
||||
mouse_move_event_index: DomRefCell<Option<usize>>,
|
||||
/// Pending animation ticks, to be handled at the next rendering opportunity.
|
||||
#[no_trace]
|
||||
#[ignore_malloc_size_of = "AnimationTickType contains data from an outside crate"]
|
||||
pending_animation_ticks: DomRefCell<AnimationTickType>,
|
||||
/// <https://drafts.csswg.org/resize-observer/#dom-document-resizeobservers-slot>
|
||||
///
|
||||
/// Note: we are storing, but never removing, resize observers.
|
||||
|
@ -2397,10 +2391,6 @@ impl Document {
|
|||
pub(crate) fn run_the_animation_frame_callbacks(&self, can_gc: CanGc) {
|
||||
let _realm = enter_realm(self);
|
||||
|
||||
self.pending_animation_ticks
|
||||
.borrow_mut()
|
||||
.remove(AnimationTickType::REQUEST_ANIMATION_FRAME);
|
||||
|
||||
self.running_animation_callbacks.set(true);
|
||||
let was_faking_animation_frames = self.is_faking_animation_frames();
|
||||
let timing = self.global().performance().Now();
|
||||
|
@ -3916,7 +3906,6 @@ impl Document {
|
|||
image_animation_manager: DomRefCell::new(ImageAnimationManager::new()),
|
||||
dirty_root: Default::default(),
|
||||
declarative_refresh: Default::default(),
|
||||
pending_animation_ticks: Default::default(),
|
||||
pending_input_events: Default::default(),
|
||||
mouse_move_event_index: Default::default(),
|
||||
resize_observers: Default::default(),
|
||||
|
@ -4689,18 +4678,6 @@ impl Document {
|
|||
.collect()
|
||||
}
|
||||
|
||||
/// Note a pending animation tick, to be processed at the next `update_the_rendering` task.
|
||||
pub(crate) fn note_pending_animation_tick(&self, tick_type: AnimationTickType) {
|
||||
self.pending_animation_ticks.borrow_mut().extend(tick_type);
|
||||
}
|
||||
|
||||
/// Whether this document has received an animation tick for rafs.
|
||||
pub(crate) fn has_received_raf_tick(&self) -> bool {
|
||||
self.pending_animation_ticks
|
||||
.borrow()
|
||||
.contains(AnimationTickType::REQUEST_ANIMATION_FRAME)
|
||||
}
|
||||
|
||||
pub(crate) fn advance_animation_timeline_for_testing(&self, delta: f64) {
|
||||
self.animation_timeline.borrow_mut().advance_specific(delta);
|
||||
let current_timeline_value = self.current_animation_timeline_value();
|
||||
|
@ -6437,10 +6414,7 @@ impl FakeRequestAnimationFrameCallback {
|
|||
pub(crate) fn invoke(self, can_gc: CanGc) {
|
||||
// TODO: Once there is a more generic mechanism to trigger `update_the_rendering` when
|
||||
// not driven by the compositor, it should be used here.
|
||||
self.document
|
||||
.root()
|
||||
.note_pending_animation_tick(AnimationTickType::REQUEST_ANIMATION_FRAME);
|
||||
with_script_thread(|script_thread| script_thread.update_the_rendering(false, can_gc))
|
||||
with_script_thread(|script_thread| script_thread.update_the_rendering(true, can_gc))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue