diff --git a/content/media/MediaStreamGraph.cpp b/content/media/MediaStreamGraph.cpp index e537b99fb546..34a7cb4aa546 100644 --- a/content/media/MediaStreamGraph.cpp +++ b/content/media/MediaStreamGraph.cpp @@ -2789,9 +2789,15 @@ MediaStreamGraphImpl::CollectReports(nsIHandleReportCallback* aHandleReport, 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; }