diff --git a/dom/media/MediaDecoderStateMachine.cpp b/dom/media/MediaDecoderStateMachine.cpp index 5fa8921063bf..3b66e15411a6 100644 --- a/dom/media/MediaDecoderStateMachine.cpp +++ b/dom/media/MediaDecoderStateMachine.cpp @@ -2411,7 +2411,10 @@ void MediaDecoderStateMachine::RecomputeDuration() duration = TimeUnit::FromSeconds(d); } else if (mEstimatedDuration.Ref().isSome()) { duration = mEstimatedDuration.Ref().ref(); - } else if (Info().mMetadataDuration.isSome()) { + } else if (mInfo.isSome() && Info().mMetadataDuration.isSome()) { + // We need to check mInfo.isSome() because that this method might be invoked + // while mObservedDuration is changed which might before the metadata been + // read. duration = Info().mMetadataDuration.ref(); } else { return;