Bug 1278443 - Part 1: Don't open PBackground actors after PContentChild is closed. r=billm, a=gchang
authorCervantes Yu <cyu@mozilla.com>
Tue, 04 Oct 2016 17:48:46 +0800
changeset 356317 1c139f0cb56dfee21a45d2bda958a18f707939bd
parent 356316 a7aa5b40eaeaec9d277fdf66709c6765b44d926e
child 356318 a2f59a3641b8462377dbef1ca9396faab060f22b
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm, gchang
bugs1278443
milestone51.0a2
Bug 1278443 - Part 1: Don't open PBackground actors after PContentChild is closed. r=billm, a=gchang MozReview-Commit-ID: FMtHF3yMQFG
dom/media/systemservices/CamerasChild.cpp
ipc/glue/BackgroundImpl.cpp
--- a/dom/media/systemservices/CamerasChild.cpp
+++ b/dom/media/systemservices/CamerasChild.cpp
@@ -82,19 +82,20 @@ public:
     ipc::PBackgroundChild* existingBackgroundChild =
       ipc::BackgroundChild::GetForCurrentThread();
     // If it's not spun up yet, block until it is, and retry
     if (!existingBackgroundChild) {
       LOG(("No existingBackgroundChild"));
       existingBackgroundChild =
         ipc::BackgroundChild::SynchronouslyCreateForCurrentThread();
       LOG(("BackgroundChild: %p", existingBackgroundChild));
+      if (!existingBackgroundChild) {
+        return NS_ERROR_FAILURE;
+      }
     }
-    // By now PBackground is guaranteed to be up
-    MOZ_RELEASE_ASSERT(existingBackgroundChild);
 
     // Create CamerasChild
     // We will be returning the resulting pointer (synchronously) to our caller.
     mCamerasChild =
       static_cast<mozilla::camera::CamerasChild*>(existingBackgroundChild->SendPCamerasConstructor());
 
     return NS_OK;
   }
--- a/ipc/glue/BackgroundImpl.cpp
+++ b/ipc/glue/BackgroundImpl.cpp
@@ -2028,16 +2028,23 @@ ChildImpl::OpenProtocolOnMainThread(nsIE
     }
 
     return true;
   }
 
   ContentChild* content = ContentChild::GetSingleton();
   MOZ_ASSERT(content);
 
+  if (content->IsShuttingDown()) {
+    // The transport for ContentChild is shut down and can't be used to open
+    // PBackground.
+    DispatchFailureCallback(aEventTarget);
+    return false;
+  }
+
   if (!PBackground::Open(content)) {
     MOZ_CRASH("Failed to create top level actor!");
     return false;
   }
 
   if (!sPendingTargets) {
     sPendingTargets = new nsTArray<nsCOMPtr<nsIEventTarget>>(1);
     ClearOnShutdown(&sPendingTargets);