Bug 1384578 - Adjust the calling sequence to avoid app crash by race condition. r=jolin
authorJames Cheng <jacheng@mozilla.com>
Mon, 31 Jul 2017 11:23:29 +0800
changeset 420662 116f553ba4cd6cfbe721c69047e68b1b4c0bcc86
parent 420661 10878b3f929da4cf2257a196a2669d424c152012
child 420663 b1dcb20102b7598ec4d467530cd20ba9e8754de6
child 420676 3a7473bd9db5f2741725b436cbcb976b7922a937
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjolin
bugs1384578
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 1384578 - Adjust the calling sequence to avoid app crash by race condition. r=jolin MozReview-Commit-ID: JKtfNYTTCjp
dom/media/hls/HLSDemuxer.cpp
dom/media/hls/HLSResource.cpp
--- a/dom/media/hls/HLSDemuxer.cpp
+++ b/dom/media/hls/HLSDemuxer.cpp
@@ -248,24 +248,24 @@ HLSDemuxer::OnTaskQueue() const
 {
   return mTaskQueue->IsCurrentThreadIn();
 }
 
 HLSDemuxer::~HLSDemuxer()
 {
   HLS_DEBUG("HLSDemuxer", "~HLSDemuxer()");
   mCallbackSupport->Detach();
-  if (mJavaCallbacks) {
-    HLSDemuxerCallbacksSupport::DisposeNative(mJavaCallbacks);
-    mJavaCallbacks = nullptr;
-  }
   if (mHLSDemuxerWrapper) {
     mHLSDemuxerWrapper->Destroy();
     mHLSDemuxerWrapper = nullptr;
   }
+  if (mJavaCallbacks) {
+      HLSDemuxerCallbacksSupport::DisposeNative(mJavaCallbacks);
+      mJavaCallbacks = nullptr;
+  }
   mInitPromise.RejectIfExists(NS_ERROR_DOM_MEDIA_CANCELED, __func__);
 }
 
 HLSTrackDemuxer::HLSTrackDemuxer(HLSDemuxer* aParent,
                                  TrackInfo::TrackType aType,
                                  UniquePtr<TrackInfo> aTrackInfo)
   : mParent(aParent)
   , mType(aType)
--- a/dom/media/hls/HLSResource.cpp
+++ b/dom/media/hls/HLSResource.cpp
@@ -95,19 +95,19 @@ void HLSResource::Resume()
 
 HLSResource::~HLSResource()
 {
   HLS_DEBUG("HLSResource", "~HLSResource()");
   if (mCallbackSupport) {
     mCallbackSupport->Detach();
     mCallbackSupport = nullptr;
   }
-  if (mJavaCallbacks) {
-    HLSResourceCallbacksSupport::DisposeNative(mJavaCallbacks);
-    mJavaCallbacks = nullptr;
-  }
   if (mHLSResourceWrapper) {
     mHLSResourceWrapper->Destroy();
     mHLSResourceWrapper = nullptr;
   }
+  if (mJavaCallbacks) {
+      HLSResourceCallbacksSupport::DisposeNative(mJavaCallbacks);
+      mJavaCallbacks = nullptr;
+  }
 }
 
 } // namespace mozilla