Bug 1411318 - Don't consider an animation playing if its timeline is inactive; r?hiro
When we receive animations on the compositor, we assert that either they're not
playing, or they have a resolved start and origin time.
However, on the main thread we determine if an animation is playing by checking
if it has a timeline, if it's in the correct state, and if it has a non-zero
playback rate.
The problem with this check is that if an animation has a timeline but it is
inactive, that is, its current time is null, we will not be able to get
a resolved origin time -- yet we will still report that is is playing.
This patch fixes this mismatch by treating animations with an inactive timeline
as "not playing".
The IsPlaying() method is used a number of call sites but it appears that they
all would expect an animation with an inactive timeline to be considered "not
playing". Furthermore, this makes IsPlaying() consistent with the check we do
for an active timeline in other functions such as Animation::Tick(),
TriggerNow(), SilentlySetCurrentTime(), UpdateFinishedState(),
and IsPossibleOrphanedPendingAnimation().
MozReview-Commit-ID: BQOBpHHFMoD
--- a/dom/animation/Animation.h
+++ b/dom/animation/Animation.h
@@ -275,16 +275,17 @@ public:
{
return GetEffect() && GetEffect()->IsInEffect();
}
bool IsPlaying() const
{
return mPlaybackRate != 0.0 &&
mTimeline &&
+ !mTimeline->GetCurrentTime().IsNull() &&
(PlayState() == AnimationPlayState::Running ||
mPendingState == PendingState::PlayPending);
}
bool ShouldBeSynchronizedWithMainThread(
nsCSSPropertyID aProperty,
const nsIFrame* aFrame,
AnimationPerformanceWarning::Type& aPerformanceWarning) const;
new file mode 100644
--- /dev/null
+++ b/dom/animation/test/crashtests/1411318-1.html
@@ -0,0 +1,15 @@
+<html>
+ <head>
+ <script>
+ o1 = (new DOMParser).parseFromString('', 'text/html');
+ o2 = document.createElement('canvas');
+ document.documentElement.appendChild(o2);
+ o3 = o2.animate([{'transform':'unset'}], {'delay':32});
+ o4 = o3.effect;
+ o5 = o1.createElement('d');
+ o6 = new Animation(o4, document.timeline);
+ o7 = o5.animate([], {});
+ o7.effect = o6.effect;
+ </script>
+ </head>
+</html>
--- a/dom/animation/test/crashtests/crashtests.list
+++ b/dom/animation/test/crashtests/crashtests.list
@@ -32,8 +32,9 @@ pref(dom.animations-api.core.enabled,tru
pref(dom.animations-api.core.enabled,true) load 1335998-1.html
pref(dom.animations-api.core.enabled,true) load 1343589-1.html
pref(dom.animations-api.core.enabled,true) load 1359658-1.html
pref(dom.animations-api.core.enabled,true) load 1373712-1.html
pref(dom.animations-api.core.enabled,true) load 1379606-1.html
pref(dom.animations-api.core.enabled,true) load 1393605-1.html
load 1400022-1.html
pref(dom.animations-api.core.enabled,true) load 1401809.html
+pref(dom.animations-api.core.enabled,true) load 1411318-1.html