diff options
author | Martin Robinson <mrobinson@igalia.com> | 2023-04-25 10:48:13 +0200 |
---|---|---|
committer | Martin Robinson <mrobinson@igalia.com> | 2023-05-02 08:37:15 +0200 |
commit | 17e3f34e65052d6f34450e9c9b0248b793c68753 (patch) | |
tree | 16c1393efe8feac4c8a9d93ed880cd64be818e10 /components/script/animations.rs | |
parent | 2691d2a8f3a9d899b4ec6a9d061b8ffd733c76dd (diff) | |
download | servo-17e3f34e65052d6f34450e9c9b0248b793c68753.tar.gz servo-17e3f34e65052d6f34450e9c9b0248b793c68753.zip |
Fix flakiness in animation tests
1. When updating the animation timeline, ensure that nodes that are
animating are marked dirty, if necessary, so any style queries will
force an layout flush.
2. Disable the problematic transition test suites, as they are in Gecko.
These suites often fail when Servo is so overloaded that it cannot
deliver frames fast enough to get more than two samples during the
animation lifecycle.
Fixes #28334.
Fixes #26435.
Fixes #21486.
Diffstat (limited to 'components/script/animations.rs')
-rw-r--r-- | components/script/animations.rs | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/components/script/animations.rs b/components/script/animations.rs index 73131763430..49dfe77e1b4 100644 --- a/components/script/animations.rs +++ b/components/script/animations.rs @@ -2,8 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -#![deny(missing_docs)] - //! The set of animations for a document. use crate::dom::animationevent::AnimationEvent; @@ -47,6 +45,11 @@ pub(crate) struct Animations { /// A list of pending animation-related events. pending_events: DomRefCell<Vec<TransitionOrAnimationEvent>>, + + /// The timeline value at the last time all animations were marked dirty. + /// This is used to prevent marking animations dirty when the timeline + /// has not changed. + timeline_value_at_last_dirty: Cell<f64>, } impl Animations { @@ -56,6 +59,7 @@ impl Animations { has_running_animations: Cell::new(false), rooted_nodes: Default::default(), pending_events: Default::default(), + timeline_value_at_last_dirty: Cell::new(0.0), } } @@ -65,12 +69,23 @@ impl Animations { self.pending_events.borrow_mut().clear(); } - pub(crate) fn mark_animating_nodes_as_dirty(&self) { + // Mark all animations dirty, if they haven't been marked dirty since the + // specified `current_timeline_value`. Returns true if animations were marked + // dirty or false otherwise. + pub(crate) fn mark_animating_nodes_as_dirty(&self, current_timeline_value: f64) -> bool { + if current_timeline_value <= self.timeline_value_at_last_dirty.get() { + return false; + } + self.timeline_value_at_last_dirty + .set(current_timeline_value); + let sets = self.sets.sets.read(); let rooted_nodes = self.rooted_nodes.borrow(); for node in sets.keys().filter_map(|key| rooted_nodes.get(&key.node)) { node.dirty(NodeDamage::NodeStyleDamaged); } + + true } pub(crate) fn update_for_new_timeline_value(&self, window: &Window, now: f64) { @@ -97,7 +112,6 @@ impl Animations { } self.unroot_unused_nodes(&sets); - //self.update_running_animations_presence(window); } /// Cancel animations for the given node, if any exist. |