diff options
author | Martin Robinson <mrobinson@igalia.com> | 2025-04-24 21:03:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-24 19:03:14 +0000 |
commit | cbc363bedd5f48e08b4311b00421256d38bf488e (patch) | |
tree | 5c8ac6c1ac5193357b5f28da8c8fc6da1d1e62a8 /components/shared | |
parent | 3793936f05ca83f04687d769ba29d84f271c67f2 (diff) | |
download | servo-cbc363bedd5f48e08b4311b00421256d38bf488e.tar.gz servo-cbc363bedd5f48e08b4311b00421256d38bf488e.zip |
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>
Diffstat (limited to 'components/shared')
-rw-r--r-- | components/shared/constellation/lib.rs | 17 | ||||
-rw-r--r-- | components/shared/script/lib.rs | 4 |
2 files changed, 5 insertions, 16 deletions
diff --git a/components/shared/constellation/lib.rs b/components/shared/constellation/lib.rs index 548e17b532c..b3d4fe525a1 100644 --- a/components/shared/constellation/lib.rs +++ b/components/shared/constellation/lib.rs @@ -18,7 +18,6 @@ use std::time::Duration; use base::Epoch; use base::cross_process_instant::CrossProcessInstant; use base::id::{MessagePortId, PipelineId, WebViewId}; -use bitflags::bitflags; use embedder_traits::{ CompositorHitTestResult, Cursor, InputEvent, MediaSessionActionType, Theme, ViewportDetails, WebDriverCommandMsg, @@ -57,8 +56,9 @@ pub enum EmbedderToConstellationMessage { ChangeViewportDetails(WebViewId, ViewportDetails, WindowSizeType), /// Inform the constellation of a theme change. ThemeChange(Theme), - /// Requests that the constellation instruct layout to begin a new tick of the animation. - TickAnimation(PipelineId, AnimationTickType), + /// Requests that the constellation instruct script/layout to try to layout again and tick + /// animations. + TickAnimation(Vec<WebViewId>), /// Dispatch a webdriver command WebDriverCommand(WebDriverCommandMsg), /// Reload a top-level browsing context. @@ -130,17 +130,6 @@ pub enum WindowSizeType { Resize, } -bitflags! { - #[derive(Debug, Default, Deserialize, Serialize)] - /// Specifies if rAF should be triggered and/or CSS Animations and Transitions. - pub struct AnimationTickType: u8 { - /// Trigger a call to requestAnimationFrame. - const REQUEST_ANIMATION_FRAME = 0b001; - /// Trigger restyles for CSS Animations and Transitions. - const CSS_ANIMATIONS_AND_TRANSITIONS = 0b010; - } -} - /// The scroll state of a stacking context. #[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] pub struct ScrollState { diff --git a/components/shared/script/lib.rs b/components/shared/script/lib.rs index a39be739fd5..7323907cba3 100644 --- a/components/shared/script/lib.rs +++ b/components/shared/script/lib.rs @@ -20,7 +20,7 @@ use bluetooth_traits::BluetoothRequest; use canvas_traits::webgl::WebGLPipeline; use compositing_traits::CrossProcessCompositorApi; use constellation_traits::{ - AnimationTickType, LoadData, NavigationHistoryBehavior, ScriptToConstellationChan, ScrollState, + LoadData, NavigationHistoryBehavior, ScriptToConstellationChan, ScrollState, StructuredSerializedData, WindowSizeType, }; use crossbeam_channel::{RecvTimeoutError, Sender}; @@ -195,7 +195,7 @@ pub enum ScriptThreadMessage { /// Passes a webdriver command to the script thread for execution WebDriverScriptCommand(PipelineId, WebDriverScriptCommand), /// Notifies script thread that all animations are done - TickAllAnimations(PipelineId, AnimationTickType), + TickAllAnimations(Vec<WebViewId>), /// Notifies the script thread that a new Web font has been loaded, and thus the page should be /// reflowed. WebFontLoaded(PipelineId, bool /* success */), |