Bug 1620660 - Drop frames in VideoConduit if they are cropped to zero width or height; r=ng
authorDan Minor <dminor@mozilla.com>
Tue, 10 Mar 2020 19:44:13 +0000
changeset 518188 649a2a4d16d088b116976231b73b3defdf6e5e5f
parent 518187 cf995779fc05c87b8d941a9698528fd8e6276a56
child 518189 1313df275548899d287430ee34551a7bb398f6ed
push id37206
push useraciure@mozilla.com
push dateThu, 12 Mar 2020 03:57:49 +0000
treeherdermozilla-central@4fd5c458be4c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersng
bugs1620660, 1521169
milestone76.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 1620660 - Drop frames in VideoConduit if they are cropped to zero width or height; r=ng Failing to drop frames if they are cropped to zero width and height leads to the crash seen in Bug 1521169. We get a call to CreateEncoderStreams requesting streams with zero width and height at which point it is too late to do anything, because the webrtc.org code making the call always expects CreateEncoderStreams to always return at least one stream, and it can't handle streams with zero width or height. Depends on D65799 Differential Revision: https://phabricator.services.mozilla.com/D65800
media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
--- a/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
+++ b/media/webrtc/signaling/src/media-conduit/VideoConduit.cpp
@@ -1914,16 +1914,22 @@ MediaConduitErrorCode WebrtcVideoConduit
             frame.width(), frame.height(),
             frame.timestamp_us() * rtc::kNumNanosecsPerMicrosec, &cropWidth,
             &cropHeight, &adaptedWidth, &adaptedHeight)) {
       // VideoAdapter dropped the frame.
       return kMediaConduitNoError;
     }
   }
 
+  // If we have zero width or height, drop the frame here. Attempting to send
+  // it will cause all sorts of problems in the webrtc.org code.
+  if (cropWidth == 0 || cropHeight == 0) {
+    return kMediaConduitNoError;
+  }
+
   int cropX = (frame.width() - cropWidth) / 2;
   int cropY = (frame.height() - cropHeight) / 2;
 
   rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer;
   if (adaptedWidth == frame.width() && adaptedHeight == frame.height()) {
     // No adaption - optimized path.
     buffer = frame.video_frame_buffer();
   } else {