Bug 1402584 - add logs for debugging. See comment 5 for the detail. draft
authorJW Wang <jwwang@mozilla.com>
Mon, 02 Oct 2017 13:51:04 +0800
changeset 675275 84dfe20bc60c2f31a117894ac425da48abc91aca
parent 673183 7279714334aeeed9794de1db183e8f46db893c48
child 734560 af5b3451e546e02b0ef0659a2fc0dc0d57cf5f44
push id83085
push userjwwang@mozilla.com
push dateThu, 05 Oct 2017 02:41:32 +0000
bugs1402584
milestone58.0a1
Bug 1402584 - add logs for debugging. See comment 5 for the detail. MozReview-Commit-ID: 48zKkVt5hbK
dom/html/HTMLMediaElement.cpp
dom/media/MediaDecoder.h
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -2828,16 +2828,27 @@ HTMLMediaElement::Seek(double aTime,
   //       actual seek target before beginning the synchronous section, but
   //       that requires changing all MediaDecoderReaders to support telling
   //       us the fastSeek target, and it's currently not possible to get
   //       this information as we don't yet control the demuxer for all
   //       MediaDecoderReaders.
 
   mPlayingBeforeSeek = IsPotentiallyPlaying();
 
+#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
+  if (!mDecoder->IsMetadataLoaded()) {
+    // This is for debugging bug 1402584.
+    // We should reach here only after metadata loaded by the decoder.
+    MOZ_CRASH_UNSAFE_PRINTF(
+      "Metadata not loaded! readyState=%d networkState=%d",
+      static_cast<int>(mReadyState.Ref()),
+      static_cast<int>(mNetworkState));
+  }
+#endif
+
   // The media backend is responsible for dispatching the timeupdate
   // event if it changes the playback position as a result of the seek.
   LOG(LogLevel::Debug, ("%p SetCurrentTime(%f) starting seek", this, aTime));
   nsresult rv = mDecoder->Seek(aTime, aSeekType);
   if (NS_FAILED(rv)) {
     aRv.Throw(rv);
     return nullptr;
   }
@@ -5902,16 +5913,26 @@ void HTMLMediaElement::ChangeReadyState(
   }
 
   CheckAutoplayDataReady();
 
   if (oldState < nsIDOMHTMLMediaElement::HAVE_ENOUGH_DATA &&
       mReadyState >= nsIDOMHTMLMediaElement::HAVE_ENOUGH_DATA) {
     DispatchAsyncEvent(NS_LITERAL_STRING("canplaythrough"));
   }
+
+#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
+  if (mReadyState >= nsIDOMHTMLMediaElement::HAVE_METADATA && mDecoder &&
+      !mDecoder->IsMetadataLoaded()) {
+    MOZ_CRASH_UNSAFE_PRINTF(
+      "Metadata not loaded! readyState=%d networkState=%d",
+      static_cast<int>(mReadyState.Ref()),
+      static_cast<int>(mNetworkState));
+  }
+#endif
 }
 
 static const char* const gNetworkStateToString[] = {
   "EMPTY",
   "IDLE",
   "LOADING",
   "NO_SOURCE"
  };
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -234,16 +234,19 @@ public:
 
   MediaDecoderStateMachine* GetStateMachine() const;
   void SetStateMachine(MediaDecoderStateMachine* aStateMachine);
 
   // Constructs the time ranges representing what segments of the media
   // are buffered and playable.
   virtual media::TimeIntervals GetBuffered();
 
+  // For debugging bug 1402584.
+  bool IsMetadataLoaded() const { return !!mInfo; }
+
   // Returns the size, in bytes, of the heap memory used by the currently
   // queued decoded video and audio data.
   size_t SizeOfVideoQueue();
   size_t SizeOfAudioQueue();
 
   // Helper struct for accumulating resource sizes that need to be measured
   // asynchronously. Once all references are dropped the callback will be
   // invoked.