Backed out changeset b5067fbd502e (bug 1022376) for Android crashes during 408431-1.html
authorEd Morley <emorley@mozilla.com>
Mon, 09 Jun 2014 12:14:27 +0100
changeset 208392 dc93584a0948d18d4e8a69a14a14fc915fc720d5
parent 208391 a31a36670f9251f54a19afcfa3db69eae59c5276
child 208393 008243793ef803bdbaed06190621d297f761d23f
push id3857
push userraliiev@mozilla.com
push dateTue, 02 Sep 2014 16:39:23 +0000
treeherdermozilla-beta@5638b907b505 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1022376, 408431
milestone32.0a1
backs outb5067fbd502ee7ff5d7e6b0a54edcd6d0fcd847f
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
Backed out changeset b5067fbd502e (bug 1022376) for Android crashes during 408431-1.html
content/media/webrtc/LoadManager.cpp
content/media/webrtc/LoadMonitor.cpp
--- a/content/media/webrtc/LoadManager.cpp
+++ b/content/media/webrtc/LoadManager.cpp
@@ -53,17 +53,16 @@ LoadManager::LoadManager(int aLoadMeasur
   MOZ_ASSERT(mHighLoadThreshold > mLowLoadThreshold);
   mLoadMonitor = new LoadMonitor(mLoadMeasurementInterval);
   mLoadMonitor->Init(mLoadMonitor);
   mLoadMonitor->SetLoadChangeCallback(this);
 }
 
 LoadManager::~LoadManager()
 {
-  LOG(("LoadManager: shutting down LoadMonitor"));
   mLoadMonitor->Shutdown();
 }
 
 void
 LoadManager::LoadChanged(float aSystemLoad, float aProcesLoad)
 {
   // Update total load, and total amount of measured seconds.
   mLoadSum += aSystemLoad;
--- a/content/media/webrtc/LoadMonitor.cpp
+++ b/content/media/webrtc/LoadMonitor.cpp
@@ -144,27 +144,21 @@ public:
   }
 
 private:
   nsRefPtr<LoadMonitor> mLoadMonitor;
 };
 
 void LoadMonitor::Shutdown()
 {
+  MutexAutoLock lock(mLock);
   if (mLoadInfoThread) {
-    {
-      MutexAutoLock lock(mLock);
-      LOG(("LoadMonitor: shutting down"));
-      mShutdownPending = true;
-      mCondVar.Notify();
-    }
+    mShutdownPending = true;
+    mCondVar.Notify();
 
-    // Note: can't just call ->Shutdown() from here; that spins the event
-    // loop here, causing re-entrancy issues if we're invoked from cycle
-    // collection.  Argh.
     mLoadInfoThread = nullptr;
 
     nsRefPtr<LoadMonitorRemoveObserver> remObsRunner = new LoadMonitorRemoveObserver(this);
     if (!NS_IsMainThread()) {
       NS_DispatchToMainThread(remObsRunner);
     } else {
       remObsRunner->Run();
     }
@@ -517,41 +511,26 @@ nsresult LoadInfo::UpdateProcessLoad() {
 #endif
   return NS_OK;
 }
 
 class LoadInfoCollectRunner : public nsRunnable
 {
 public:
   LoadInfoCollectRunner(nsRefPtr<LoadMonitor> loadMonitor,
-                        RefPtr<LoadInfo> loadInfo,
-                        nsIThread *loadInfoThread)
-    : mThread(loadInfoThread),
-      mLoadUpdateInterval(loadMonitor->mLoadUpdateInterval),
+                        RefPtr<LoadInfo> loadInfo)
+    : mLoadUpdateInterval(loadMonitor->mLoadUpdateInterval),
       mLoadNoiseCounter(0)
   {
     mLoadMonitor = loadMonitor;
     mLoadInfo = loadInfo;
   }
 
   NS_IMETHOD Run()
   {
-    if (NS_IsMainThread()) {
-      if (mThread) {
-        // Don't leak threads!
-        mThread->Shutdown(); // can't Shutdown from the thread itself, darn
-        // Don't null out mThread!
-        // See bug 999104.  We must hold a ref to the thread across Dispatch()
-        // since the internal mThread ref could be released while processing
-        // the Dispatch(), and Dispatch/PutEvent itself doesn't hold a ref; it
-        // assumes the caller does.
-      }
-      return NS_OK;
-    }
-
     MutexAutoLock lock(mLoadMonitor->mLock);
     while (!mLoadMonitor->mShutdownPending) {
       mLoadInfo->UpdateSystemLoad();
       mLoadInfo->UpdateProcessLoad();
       float sysLoad = mLoadInfo->GetSystemLoad();
       float procLoad = mLoadInfo->GetProcessLoad();
 
       if ((++mLoadNoiseCounter % (LOG_MANY_ENABLED() ? 1 : 10)) == 0) {
@@ -559,23 +538,20 @@ public:
         mLoadNoiseCounter = 0;
       }
       mLoadMonitor->SetSystemLoad(sysLoad);
       mLoadMonitor->SetProcessLoad(procLoad);
       mLoadMonitor->FireCallbacks();
 
       mLoadMonitor->mCondVar.Wait(PR_MillisecondsToInterval(mLoadUpdateInterval));
     }
-    // ok, we need to exit safely and can't shut ourselves down (DARN)
-    NS_DispatchToMainThread(this);
     return NS_OK;
   }
 
 private:
-  nsCOMPtr<nsIThread> mThread;
   RefPtr<LoadInfo> mLoadInfo;
   nsRefPtr<LoadMonitor> mLoadMonitor;
   int mLoadUpdateInterval;
   int mLoadNoiseCounter;
 };
 
 void
 LoadMonitor::SetProcessLoad(float load) {
@@ -624,17 +600,17 @@ LoadMonitor::Init(nsRefPtr<LoadMonitor> 
   }
 
   nsRefPtr<LoadMonitorAddObserver> addObsRunner = new LoadMonitorAddObserver(self);
   NS_DispatchToMainThread(addObsRunner);
 
   NS_NewNamedThread("Sys Load Info", getter_AddRefs(mLoadInfoThread));
 
   nsRefPtr<LoadInfoCollectRunner> runner =
-    new LoadInfoCollectRunner(self, load_info, mLoadInfoThread);
+    new LoadInfoCollectRunner(self, load_info);
   mLoadInfoThread->Dispatch(runner, NS_DISPATCH_NORMAL);
 
   return NS_OK;
 }
 
 void
 LoadMonitor::SetLoadChangeCallback(LoadNotificationCallback* aCallback)
 {