Bug 1206948 - delay the notification of metadata to guarantee video size is correct when 'loadedmetadata' is fired in non-MSE case.
MozReview-Commit-ID: H5yQlrk7A36
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -2008,18 +2008,22 @@ MediaDecoderStateMachine::OnMetadataRead
// thus get the metadata). We could fix this if we could compute the start
// time by demuxing without necessaring decoding.
bool waitingForCDM =
#ifdef MOZ_EME
mInfo.IsEncrypted() && !mCDMProxy;
#else
false;
#endif
- mNotifyMetadataBeforeFirstFrame = mDuration.Ref().isSome() || waitingForCDM;
- if (mNotifyMetadataBeforeFirstFrame) {
+
+ // Notify metadata if it is MSE. Otherwise we will delay the event until 1st
+ // frames are decoded to workaround the case where video size in the metadata
+ // is different from that of the 1st frame.
+ if (waitingForCDM || mReader->ForceZeroStartTime()) {
+ mNotifyMetadataBeforeFirstFrame = true;
EnqueueLoadedMetadataEvent();
}
if (waitingForCDM) {
// Metadata parsing was successful but we're still waiting for CDM caps
// to become available so that we can build the correct decryptor/decoder.
SetState(DECODER_STATE_WAIT_FOR_CDM);
return;