diff --git a/dom/animation/KeyframeEffectReadOnly.cpp b/dom/animation/KeyframeEffectReadOnly.cpp index aefad6229c1e..1f3687c3264a 100644 --- a/dom/animation/KeyframeEffectReadOnly.cpp +++ b/dom/animation/KeyframeEffectReadOnly.cpp @@ -523,10 +523,19 @@ KeyframeEffectReadOnly::EnsureBaseStyles( nsPresContext* presContext = nsContentUtils::GetContextForContent(mTarget->mElement); - MOZ_ASSERT(presContext, - "nsPresContext should not be nullptr since this EnsureBaseStyles " - "supposed to be called right after getting computed values with " - "a valid nsPresContext"); + // If |aProperties| is empty we're not going to dereference |presContext| so + // we don't care if it is nullptr. + // + // We could just return early when |aProperties| is empty and save looking up + // the pres context, but that won't save any effort normally since we don't + // call this function if we have no keyframes to begin with. Furthermore, the + // case where |presContext| is nullptr is so rare (we've only ever seen in + // fuzzing, and even then we've never been able to reproduce it reliably) + // it's not worth the runtime cost of an extra branch. + MOZ_ASSERT(presContext || aProperties.IsEmpty(), + "Typically presContext should not be nullptr but if it is" + " we should have also failed to calculate the computed values" + " passed-in as aProperties"); RefPtr baseStyleContext; for (const AnimationProperty& property : aProperties) {