diff --git a/dom/animation/KeyframeEffect.cpp b/dom/animation/KeyframeEffect.cpp index 4c73aa47edb7..40949428eb99 100644 --- a/dom/animation/KeyframeEffect.cpp +++ b/dom/animation/KeyframeEffect.cpp @@ -62,7 +62,8 @@ namespace dom { NS_IMPL_CYCLE_COLLECTION_INHERITED(KeyframeEffectReadOnly, AnimationEffectReadOnly, mTarget, - mAnimation) + mAnimation, + mTiming) NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(KeyframeEffectReadOnly, AnimationEffectReadOnly) @@ -92,7 +93,7 @@ KeyframeEffectReadOnly::KeyframeEffectReadOnly( AnimationEffectTimingReadOnly* aTiming) : AnimationEffectReadOnly(aDocument) , mTarget(aTarget) - , mTiming(*aTiming) + , mTiming(aTiming) , mPseudoType(aPseudoType) , mInEffectOnLastAnimationTimingUpdate(false) { @@ -1403,7 +1404,11 @@ void KeyframeEffect::NotifySpecifiedTimingUpdated() KeyframeEffect::~KeyframeEffect() { - mTiming->Unlink(); + // mTiming is cycle collected, so we have to do null check first even though + // mTiming shouldn't be null during the lifetime of KeyframeEffect. + if (mTiming) { + mTiming->Unlink(); + } } } // namespace dom diff --git a/dom/animation/KeyframeEffect.h b/dom/animation/KeyframeEffect.h index 23998b67f37b..68b745539dd2 100644 --- a/dom/animation/KeyframeEffect.h +++ b/dom/animation/KeyframeEffect.h @@ -372,7 +372,7 @@ protected: nsCOMPtr mTarget; RefPtr mAnimation; - OwningNonNull mTiming; + RefPtr mTiming; CSSPseudoElementType mPseudoType; // The specified keyframes.