Bug 1213050: clean up TaskQueue before dropping references to it r=cpearce
authorRandell Jesup <rjesup@jesup.org>
Thu, 12 May 2016 00:53:19 -0400
changeset 338102 52abfa1b62290859f78670b3fa33eaadfbfdd694
parent 338101 95d06a6cc1acaff9ac47d9a071844f8f9e9deacd
child 338103 76a7cdabdd506567e043db46163829786fd08732
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1213050
milestone49.0a1
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
Bug 1213050: clean up TaskQueue before dropping references to it r=cpearce Also adds assertion TaskQueue isn't trying to kill itself MozReview-Commit-ID: 1AVuYcfnBBA
media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
xpcom/threads/TaskQueue.cpp
--- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
+++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp
@@ -208,23 +208,26 @@ public:
 
   bool RemoveListener(VideoConverterListener* aListener)
   {
     MutexAutoLock lock(mMutex);
 
     return mListeners.RemoveElement(aListener);
   }
 
+  void Shutdown()
+  {
+    mTaskQueue->BeginShutdown();
+    mTaskQueue->AwaitShutdownAndIdle();
+  }
+
 protected:
   virtual ~VideoFrameConverter()
   {
     MOZ_COUNT_DTOR(VideoFrameConverter);
-
-    mTaskQueue->BeginShutdown();
-    mTaskQueue->AwaitShutdownAndIdle();
   }
 
   void VideoFrameConverted(unsigned char* aVideoFrame,
                            unsigned int aVideoFrameLength,
                            unsigned short aWidth,
                            unsigned short aHeight,
                            VideoType aVideoType,
                            uint64_t aCaptureTime)
@@ -1112,16 +1115,21 @@ public:
                                             ConduitDeleteEvent(conduit_.forget()));
       MOZ_ASSERT(!NS_FAILED(rv),"Could not dispatch conduit shutdown to main");
       if (NS_FAILED(rv)) {
         MOZ_CRASH();
       }
     } else {
       conduit_ = nullptr;
     }
+#if !defined(MOZILLA_EXTERNAL_LINKAGE)
+    if (converter_) {
+      converter_->Shutdown();
+    }
+#endif
   }
 
   // Dispatches setting the internal TrackID to TRACK_INVALID to the media
   // graph thread to keep it in sync with other MediaStreamGraph operations
   // like RemoveListener() and AddListener(). The TrackID will be updated on
   // the next NewData() callback.
   void UnsetTrackId(MediaStreamGraphImpl* graph);
 
--- a/xpcom/threads/TaskQueue.cpp
+++ b/xpcom/threads/TaskQueue.cpp
@@ -94,16 +94,17 @@ TaskQueue::AwaitIdleLocked()
   while (mIsRunning) {
     mQueueMonitor.Wait();
   }
 }
 
 void
 TaskQueue::AwaitShutdownAndIdle()
 {
+  MOZ_ASSERT(!IsCurrentThreadIn());
   // Make sure there are no tasks for this queue waiting in the caller's tail
   // dispatcher.
   MOZ_ASSERT_IF(AbstractThread::GetCurrent(),
                 !AbstractThread::GetCurrent()->TailDispatcher().HasTasksFor(this));
 
   MonitorAutoLock mon(mQueueMonitor);
   while (!mIsShutdown) {
     mQueueMonitor.Wait();