Commit 3254471b authored by Henrik Boström's avatar Henrik Boström Committed by Chromium LUCI CQ

[macOS Capture] Avoid crashing on MJPEG sample buffers.

The SampleBufferTransformer CHECK-crashes if a sample buffer does not
have a pixel buffer AND is not MJPEG. But the assumption that non-pixel
buffer sample buffers most by MJPEG turns out not to hold, with the
following consequences:

In M89, this causes a CHECK-crash.
In M88, this causes a DCHECK-crash, which in official builds means we
don't crash but rather we most likely fail to decode the buffer and
return null frames. This is believed to cause "no video" issues.

This CL adds the workaround not to use the SampleBufferTransformer if
"sampleBufferLacksPixelBufferAndIsNotMjpeg" is true. So in this edge
case we fall back on the same code path that we run in M87 today.

TBR=handellm@google.com

Bug: chromium:1160647, chromium:1160315
Change-Id: I782a36cf38f5ce96a5010966c8b07aedf1b08efd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2599531Reviewed-by: default avatarHenrik Boström <hbos@chromium.org>
Commit-Queue: Henrik Boström <hbos@chromium.org>
Cr-Commit-Position: refs/heads/master@{#838638}
parent 637fd130
......@@ -693,11 +693,22 @@ AVCaptureDeviceFormat* FindBestCaptureFormat(
const base::TimeDelta timestamp = GetCMSampleBufferTimestamp(sampleBuffer);
// The SampleBufferTransformer CHECK-crashes if the sample buffer is not MJPEG
// and does not have a pixel buffer (https://crbug.com/1160647) so we fall
// back on the M87 code path if this is the case.
// TODO(https://crbug.com/1160315): When the SampleBufferTransformer is
// patched to support non-MJPEG-and-non-pixel-buffer sample buffers, remove
// this workaround.
bool sampleBufferLacksPixelBufferAndIsNotMjpeg =
!CMSampleBufferGetImageBuffer(sampleBuffer) &&
CMFormatDescriptionGetMediaSubType(CMSampleBufferGetFormatDescription(
sampleBuffer)) != kCMVideoCodecType_JPEG_OpenDML;
// If the SampleBufferTransformer is enabled, convert all possible capture
// formats to an IOSurface-backed NV12 pixel buffer.
// TODO(hbos): If |_sampleBufferTransformer| gets shipped 100%, delete the
// other code paths.
if (_sampleBufferTransformer) {
if (_sampleBufferTransformer && !sampleBufferLacksPixelBufferAndIsNotMjpeg) {
base::ScopedCFTypeRef<CVPixelBufferRef> pixelBuffer =
_sampleBufferTransformer->AutoReconfigureAndTransform(sampleBuffer);
if (!pixelBuffer) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment