Bug 1374930. P2 - add an entry only after FinishDecoderSetup() succeeds. r=cpearce
authorJW Wang <jwwang@mozilla.com>
Tue, 20 Jun 2017 15:27:45 +0800
changeset 365407 6a6012c0da0a85c1170b8fd27fc320df53552883
parent 365406 2e0273470342cb153390f017cb0b8e20fe06f140
child 365408 5627cf7a91fbe13e08f5c2bce2b7cccf0706c7d8
push id32071
push usercbook@mozilla.com
push dateThu, 22 Jun 2017 10:45:43 +0000
treeherdermozilla-central@71733bc984a1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1374930
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1374930. P2 - add an entry only after FinishDecoderSetup() succeeds. r=cpearce 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) :