Bug 1374164: guarantee mImage is released by video sources before final-cc shutdown r=padenot,jib a=lizzard
authorRandell Jesup <rjesup@jesup.org>
Mon, 14 Aug 2017 10:53:11 -0400
changeset 423741 84ec3c9fb45645b45ee29ec96877e3c5973cae2b
parent 423740 d51bedb9d492abba795601298b90a7670b19e228
child 423742 c9f31d1cd425266f7a7440b09dc03e2fb4dcf1de
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspadenot, jib, lizzard
bugs1374164
milestone56.0
Bug 1374164: guarantee mImage is released by video sources before final-cc shutdown r=padenot,jib a=lizzard MozReview-Commit-ID: 5pdiqUcps9I
dom/media/webrtc/MediaEngineCameraVideoSource.h
--- a/dom/media/webrtc/MediaEngineCameraVideoSource.h
+++ b/dom/media/webrtc/MediaEngineCameraVideoSource.h
@@ -3,16 +3,17 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MediaEngineCameraVideoSource_h
 #define MediaEngineCameraVideoSource_h
 
 #include "MediaEngine.h"
 
 #include "nsDirectoryServiceDefs.h"
+#include "mozilla/Unused.h"
 
 // conflicts with #include of scoped_ptr.h
 #undef FF
 // Avoid warnings about redefinition of WARN_UNUSED_RESULT
 #include "ipc/IPCMessageUtils.h"
 
 // WebRTC includes
 #include "webrtc/modules/video_capture/video_capture_defines.h"
@@ -55,16 +56,30 @@ public:
   {
     return NS_ERROR_NOT_IMPLEMENTED;
   }
 
   uint32_t GetBestFitnessDistance(
       const nsTArray<const NormalizedConstraintSet*>& aConstraintSets,
       const nsString& aDeviceId) const override;
 
+  void Shutdown() override
+  {
+    MonitorAutoLock lock(mMonitor);
+    // Release mImage and it's resources just in case -- also we can be
+    // held by something in a CC chain, and not be deleted until final-cc,
+    // which is too late for releasing images.  (This should be null'd on
+    // Stop(), but apparently Stop() may not get called in this case
+    // somehow.) (Bug 1374164)
+
+    Unused << NS_WARN_IF(mImage);
+
+    mImage = nullptr;
+  }
+
 protected:
   struct CapabilityCandidate {
     explicit CapabilityCandidate(uint8_t index, uint32_t distance = 0)
     : mIndex(index), mDistance(distance) {}
 
     size_t mIndex;
     uint32_t mDistance;
   };