Bug 1620660 - Drop frames in VideoConduit if they are cropped to zero width or height; r=ng a=jcristau
authorDan Minor <dminor@mozilla.com>
Tue, 10 Mar 2020 19:44:13 +0000
changeset 580516 b2b2414ac7e7fd5e2dfa89592b83aa29f20230d7
parent 580515 315ce380d25e9d5111191bc28d0526c22614f20f
child 580517 96d3f71da2ddffd32856f365cf86a65cfa21a590
push id12849
push userccoroiu@mozilla.com
push dateFri, 13 Mar 2020 17:35:16 +0000
treeherdermozilla-beta@048c7cb55745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersng, jcristau
bugs1620660, 1521169
milestone75.0
Bug 1620660 - Drop frames in VideoConduit if they are cropped to zero width or height; r=ng a=jcristau 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 {