Bug 1163239 - Check mGMPThread on shutdown. r=cpearce, a=lmandel
authorEthan Hugg <ethanhugg@gmail.com>
Mon, 11 May 2015 10:48:46 -0700
changeset 275293 c9bccf82e82cadd01e05f5a2a21ec82fe612d515
parent 275292 65ee607d815f2fb69be8553f5b0c7920b5527ba0
child 275294 b92f62aa66438661802f88027bb0e3a7fb7b7f48
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce, lmandel
bugs1163239
milestone40.0
Bug 1163239 - Check mGMPThread on shutdown. r=cpearce, a=lmandel
dom/media/gmp/GMPParent.cpp
--- a/dom/media/gmp/GMPParent.cpp
+++ b/dom/media/gmp/GMPParent.cpp
@@ -379,21 +379,31 @@ public:
   }
   nsString mNodeId;
 };
 
 void
 GMPParent::ChildTerminated()
 {
   nsRefPtr<GMPParent> self(this);
-  GMPThread()->Dispatch(NS_NewRunnableMethodWithArg<nsRefPtr<GMPParent>>(
-                          mService,
-                          &GeckoMediaPluginServiceParent::PluginTerminated,
-                          self),
-                        NS_DISPATCH_NORMAL);
+  nsIThread* gmpThread = GMPThread();
+
+  if (!gmpThread) {
+    // Bug 1163239 - this can happen on shutdown.
+    // PluginTerminated removes the GMP from the GMPService.
+    // On shutdown we can have this case where it is already been
+    // removed so there is no harm in not trying to remove it again.
+    LOGD("%s::%s: GMPThread() returned nullptr.", __CLASS__, __FUNCTION__);
+  } else {
+    gmpThread->Dispatch(NS_NewRunnableMethodWithArg<nsRefPtr<GMPParent>>(
+                         mService,
+                         &GeckoMediaPluginServiceParent::PluginTerminated,
+                         self),
+                         NS_DISPATCH_NORMAL);
+  }
 }
 
 void
 GMPParent::DeleteProcess()
 {
   LOGD("%s", __FUNCTION__);
 
   if (mState != GMPStateClosing) {