Bug 1399395 - Skip devicechange event handler in shutdown stage. r=pehrsons, a=lizzard
authorMunro Mengjue Chiang <mchiang@mozilla.com>
Thu, 14 Sep 2017 11:16:42 +0800
changeset 666734 e5b95529a8f804e828de22037d40947f60dd84a9
parent 666733 240330fb1c252763353fca8f0b6672559e32cd31
child 666735 16a31f23b98a98e4cb843658cd4a3189d0c134f4
push id80488
push userbmo:mkelly@mozilla.com
push dateTue, 19 Sep 2017 04:42:30 +0000
reviewerspehrsons, lizzard
bugs1399395
milestone56.0
Bug 1399395 - Skip devicechange event handler in shutdown stage. r=pehrsons, a=lizzard MozReview-Commit-ID: 8skWP7LuGvR
dom/media/MediaManager.cpp
--- a/dom/media/MediaManager.cpp
+++ b/dom/media/MediaManager.cpp
@@ -2064,16 +2064,19 @@ StopRawIDCallback(MediaManager *aThis,
   aListener->StopRawID(*removedDeviceID);
 }
 
 
 void MediaManager::OnDeviceChange() {
   RefPtr<MediaManager> self(this);
   NS_DispatchToMainThread(media::NewRunnableFrom([self]() mutable {
     MOZ_ASSERT(NS_IsMainThread());
+    if (sInShutdown) {
+      return NS_OK;
+    }
     self->DeviceChangeCallback::OnDeviceChange();
 
     // On some Windows machine, if we call EnumertaeRawDevices immediately after receiving
     // devicechange event, sometimes we would get outdated devices list.
     PR_Sleep(PR_MillisecondsToInterval(100));
     RefPtr<PledgeSourceSet> p = self->EnumerateRawDevices(0, MediaSourceEnum::Camera, MediaSourceEnum::Microphone, false);
     p->Then([self](SourceSet*& aDevices) mutable {
       UniquePtr<SourceSet> devices(aDevices);