Bug 1374930. P2 - add an entry only after FinishDecoderSetup() succeeds. draft
authorJW Wang <jwwang@mozilla.com>
Tue, 20 Jun 2017 15:27:45 +0800
changeset 597906 8a36827a5ac8c3689b676dda9855297918ca5181
parent 597905 7ca40d667a8eb72a2f0a416b6dea87b87a25bcbb
child 597907 485dcc697930ff161e55823e9be126f1b12c204d
child 598694 75402998582c0e79ecc7633b872f22b1adb07428
push id65083
push userjwwang@mozilla.com
push dateWed, 21 Jun 2017 06:17:02 +0000
bugs1374930
milestone56.0a1
Bug 1374930. P2 - add an entry only after FinishDecoderSetup() succeeds. MozReview-Commit-ID: 6MKRhVIZ4Z6
dom/html/HTMLMediaElement.cpp
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -4680,17 +4680,23 @@ nsresult HTMLMediaElement::InitializeDec
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   if (mChannelLoader) {
     mChannelLoader->Done();
     mChannelLoader = nullptr;
   }
 
-  return FinishDecoderSetup(decoder, resource, aListener);
+  nsresult rv = FinishDecoderSetup(decoder, resource, aListener);
+  if (NS_SUCCEEDED(rv)) {
+    AddMediaElementToURITable();
+    NS_ASSERTION(MediaElementTableCount(this, mLoadingSrc) == 1,
+      "Media element should have single table entry if decode initialized");
+  }
+  return rv;
 }
 
 nsresult HTMLMediaElement::FinishDecoderSetup(MediaDecoder* aDecoder,
                                               MediaResource* aStream,
                                               nsIStreamListener** aListener)
 {
   ChangeNetworkState(nsIDOMHTMLMediaElement::NETWORK_LOADING);
 
@@ -4746,36 +4752,31 @@ nsresult HTMLMediaElement::FinishDecoder
       mAbstractMainThread, this, &HTMLMediaElement::CannotDecryptWaitingForKey);
   }
 
   if (mChannelLoader) {
     mChannelLoader->Done();
     mChannelLoader = nullptr;
   }
 
-  AddMediaElementToURITable();
-
   // We may want to suspend the new stream now.
   // This will also do an AddRemoveSelfReference.
   NotifyOwnerDocumentActivityChanged();
 
   if (!mPaused) {
     SetPlayedOrSeeked(true);
     if (!mPausedForInactiveDocumentOrChannel) {
       rv = mDecoder->Play();
     }
   }
 
   if (NS_FAILED(rv)) {
     ShutdownDecoder();
   }
 
-  NS_ASSERTION(NS_SUCCEEDED(rv) == (MediaElementTableCount(this, mLoadingSrc) == 1),
-    "Media element should have single table entry if decode initialized");
-
   return rv;
 }
 
 class HTMLMediaElement::StreamListener : public MediaStreamListener,
                                          public WatchTarget
 {
 public:
   StreamListener(HTMLMediaElement* aElement, const char* aName) :