Bug 1209385 - Add pref to disable crashing hung GMPs. r=jwwang, a=sylvestre
authorChris Pearce <cpearce@mozilla.com>
Wed, 30 Sep 2015 06:56:20 +1300
changeset 297911 afac098c635f6cb5fc984e08a48c160f0cd43d29
parent 297910 f7fb82b98052509b881a6c28de2755fbaba1969f
child 297912 989edb32c8e5bb2b5fec369075f7ab9e07545b87
push id962
push userjlund@mozilla.com
push dateFri, 04 Dec 2015 23:28:54 +0000
treeherdermozilla-release@23a2d286e80f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwwang, sylvestre
bugs1209385
milestone43.0a2
Bug 1209385 - Add pref to disable crashing hung GMPs. r=jwwang, a=sylvestre
dom/media/gmp/GMPServiceParent.cpp
modules/libpref/init/all.js
--- a/dom/media/gmp/GMPServiceParent.cpp
+++ b/dom/media/gmp/GMPServiceParent.cpp
@@ -78,31 +78,35 @@ GeckoMediaPluginServiceParent::GetSingle
 }
 
 NS_IMPL_ISUPPORTS_INHERITED(GeckoMediaPluginServiceParent,
                             GeckoMediaPluginService,
                             mozIGeckoMediaPluginChromeService)
 
 static int32_t sMaxAsyncShutdownWaitMs = 0;
 static bool sHaveSetTimeoutPrefCache = false;
+static bool sKillHungPlugins = true;
 
 GeckoMediaPluginServiceParent::GeckoMediaPluginServiceParent()
   : mShuttingDown(false)
 #ifdef MOZ_CRASHREPORTER
   , mAsyncShutdownPluginStatesMutex("GeckoMediaPluginService::mAsyncShutdownPluginStatesMutex")
 #endif
   , mScannedPluginOnDisk(false)
   , mWaitingForPluginsSyncShutdown(false)
 {
   MOZ_ASSERT(NS_IsMainThread());
   if (!sHaveSetTimeoutPrefCache) {
     sHaveSetTimeoutPrefCache = true;
     Preferences::AddIntVarCache(&sMaxAsyncShutdownWaitMs,
                                 "media.gmp.async-shutdown-timeout",
                                 GMP_DEFAULT_ASYNC_SHUTDONW_TIMEOUT);
+    Preferences::AddBoolVarCache(&sKillHungPlugins,
+                                "media.gmp.kill-hung-plugins",
+                                true);
   }
 }
 
 GeckoMediaPluginServiceParent::~GeckoMediaPluginServiceParent()
 {
   MOZ_ASSERT(mPlugins.IsEmpty());
   MOZ_ASSERT(mAsyncShutdownPlugins.IsEmpty());
 }
@@ -1220,18 +1224,23 @@ GeckoMediaPluginServiceParent::UpdateTri
   return NS_ERROR_FAILURE;
 #endif
 }
 
 void
 GeckoMediaPluginServiceParent::CrashPluginNow(uint32_t aPluginId, GMPCrashReason aReason)
 {
   MOZ_ASSERT(NS_GetCurrentThread() == mGMPThread);
+  if (aReason == kGmpApiTimeout && !sKillHungPlugins) {
+    LOGD(("%s::%s(%u, %u) but killing hung plugins disabled.",
+          __CLASS__, __FUNCTION__, aPluginId, aReason));
+    return;
+  }
+  LOGD(("%s::%s(%u, %u)", __CLASS__, __FUNCTION__, aPluginId, aReason));
   MutexAutoLock lock(mMutex);
-  LOGD(("%s::%s(%u, %u)", __CLASS__, __FUNCTION__, aPluginId, aReason));
   for (const auto& plugin : mPlugins) {
     if (plugin->GetPluginId() == aPluginId) {
       plugin->Crash(aReason);
     }
   }
 }
 
 static bool
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -302,16 +302,18 @@ pref("media.play-stand-alone", true);
 // attribute until the media element's owner document is visible.
 pref("media.block-play-until-visible", false);
 
 pref("media.hardware-video-decoding.enabled", true);
 
 pref("media.decoder.heuristic.dormant.enabled", true);
 pref("media.decoder.heuristic.dormant.timeout", 60000);
 
+pref("media.gmp.kill-hung-plugins", true);
+
 #ifdef MOZ_WMF
 pref("media.wmf.decoder.thread-count", -1);
 #endif
 #ifdef MOZ_DIRECTSHOW
 pref("media.directshow.enabled", true);
 #endif
 #ifdef MOZ_FMP4
 pref("media.fragmented-mp4.enabled", true);