Bug 1518982 - Don't register animations with playbackRate == 0 with a timeline; r=hiro
authorBrian Birtles <birtles@gmail.com>
Thu, 10 Jan 2019 06:56:09 +0000
changeset 510314 2f4920fa4ac7c36c79057fa4c1a7e5a212d025aa
parent 510313 87e21b003b079e91d7e833853116a343fcae8cee
child 510315 90a1ff49b6b1463090cb19cbc54a85f152f2488f
push id10547
push userffxbld-merge
push dateMon, 21 Jan 2019 13:03:58 +0000
treeherdermozilla-beta@24ec1916bffe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershiro
bugs1518982
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1518982 - Don't register animations with playbackRate == 0 with a timeline; r=hiro Differential Revision: https://phabricator.services.mozilla.com/D16153
dom/animation/Animation.h
--- a/dom/animation/Animation.h
+++ b/dom/animation/Animation.h
@@ -146,17 +146,27 @@ class Animation : public DOMEventTargetH
 
   void UpdatePlaybackRate(double aPlaybackRate);
   void Reverse(ErrorResult& aRv);
 
   bool IsRunningOnCompositor() const;
 
   virtual void Tick();
   bool NeedsTicks() const {
-    return Pending() || PlayState() == AnimationPlayState::Running;
+    return Pending() ||
+           (PlayState() == AnimationPlayState::Running &&
+            // An animation with a zero playback rate doesn't need ticks even if
+            // it is running since it effectively behaves as if it is paused.
+            //
+            // It's important we return false in this case since a zero playback
+            // rate animation in the before or after phase that doesn't fill
+            // won't be relevant and hence won't be returned by GetAnimations().
+            // We don't want its timeline to keep it alive (which would happen
+            // if we return true) since otherwise it will effectively be leaked.
+            PlaybackRate() != 0.0);
   }
 
   /**
    * Set the time to use for starting or pausing a pending animation.
    *
    * Typically, when an animation is played, it does not start immediately but
    * is added to a table of pending animations on the document of its effect.
    * In the meantime it sets its hold time to the time from which playback