Bug 1036679 - MediaStreamGraph shutdown can hang if happening in conjunction with a memory report. r=roc, a=2.0+
authorEric Rahm <erahm@mozilla.com>
Wed, 09 Jul 2014 17:22:37 -0700
changeset 207899 0061c1fe7e28f94a15dc9373dd2914ddc8db5b1a
parent 207898 0e6ed467cb4dc988288e1b39bc7b4a866e004214
child 207900 a8b32e56b4f0346b4a63218350f582682e1f32ac
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, 2
bugs1036679
milestone32.0a2
Bug 1036679 - MediaStreamGraph shutdown can hang if happening in conjunction with a memory report. r=roc, a=2.0+
content/media/MediaStreamGraph.cpp
--- a/content/media/MediaStreamGraph.cpp
+++ b/content/media/MediaStreamGraph.cpp
@@ -2799,19 +2799,25 @@ MediaStreamGraphImpl::CollectReports(nsI
     mNeedsMemoryReport = true;
 
     {
       // Wake up the MSG thread.
       MonitorAutoLock monitorLock(mMonitor);
       EnsureImmediateWakeUpLocked(monitorLock);
     }
 
-    // Wait for the report to complete.
+    if (mLifecycleState >= LIFECYCLE_WAITING_FOR_THREAD_SHUTDOWN) {
+      // Shutting down, nothing to report.
+      return NS_OK;
+    }
+
+    // Wait for up to one second for the report to complete.
     nsresult rv;
-    while ((rv = memoryReportLock.Wait()) != NS_OK) {
+    const PRIntervalTime kMaxWait = PR_SecondsToInterval(1);
+    while ((rv = memoryReportLock.Wait(kMaxWait)) != NS_OK) {
       if (PR_GetError() != PR_PENDING_INTERRUPT_ERROR) {
         return rv;
       }
     }
   }
 
 #define REPORT(_path, _amount, _desc)                                       \
   do {                                                                      \