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
|
@ -1147,14 +1147,6 @@ impl ScriptThread {
|
|||
return;
|
||||
}
|
||||
|
||||
// Run rafs for all pipeline, if a raf tick was received for any.
|
||||
// This ensures relative ordering of rafs between parent doc and iframes.
|
||||
let should_run_rafs = self
|
||||
.documents
|
||||
.borrow()
|
||||
.iter()
|
||||
.any(|(_, doc)| doc.is_fully_active() && doc.has_received_raf_tick());
|
||||
|
||||
let any_animations_running = self.documents.borrow().iter().any(|(_, document)| {
|
||||
document.is_fully_active() && document.animations().running_animation_count() != 0
|
||||
});
|
||||
|
@ -1242,7 +1234,7 @@ impl ScriptThread {
|
|||
// > 14. For each doc of docs, run the animation frame callbacks for doc, passing
|
||||
// > in the relative high resolution time given frameTimestamp and doc's
|
||||
// > relevant global object as the timestamp.
|
||||
if should_run_rafs {
|
||||
if requested_by_compositor {
|
||||
document.run_the_animation_frame_callbacks(can_gc);
|
||||
}
|
||||
|
||||
|
@ -1421,18 +1413,9 @@ impl ScriptThread {
|
|||
self.handle_viewport(id, rect);
|
||||
}),
|
||||
MixedMessage::FromConstellation(ScriptThreadMessage::TickAllAnimations(
|
||||
pipeline_id,
|
||||
tick_type,
|
||||
_webviews,
|
||||
)) => {
|
||||
if let Some(document) = self.documents.borrow().find_document(pipeline_id) {
|
||||
document.note_pending_animation_tick(tick_type);
|
||||
compositor_requested_update_the_rendering = true;
|
||||
} else {
|
||||
warn!(
|
||||
"Trying to note pending animation tick for closed pipeline {}.",
|
||||
pipeline_id
|
||||
)
|
||||
}
|
||||
compositor_requested_update_the_rendering = true;
|
||||
},
|
||||
MixedMessage::FromConstellation(ScriptThreadMessage::SendInputEvent(id, event)) => {
|
||||
self.handle_input_event(id, event)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue