DescriptionFix for Crash in VideoCaptureController::DoNewBufferOnIOThread.
Crash reports[1] indicate that it can happen that VideoCaptureController
receives frames while its |frame_buffer_pool_| is null.
The cause appears to be due to a race condition that I missed in both the
original CL[2] and the reland[3], where VideoCaptureController receives a frame
before a FrameBufferPool has been set (during device startup) or after
FrameBufferPool has been reset to nullptr (during deivce stop).
The race condition during startup can only happen if the device delivers frames
on a private internal thread different from the "device thread" that calls
AllocateAndStart()). Below are example sequences (as indicated by the numbers)
where VideoCaptureController would receive frames while FrameBufferPool is null:
Device Startup Case
IO Thread:
1. Issue CreateAndStartDevice to Device Thread
8. Receive DeviceStarted callback
9. SetFrameBufferPool
6. Receive OnFrame message
Device Thread:
2. CreateDevice
3. StartDevice
7. Issue DeviceStarted callback to IO Thread
Capture and Delivery Thread:
4. Capture frame
5. Issue OnFrame message to IO Thread
Device Stop Case
IO Thread:
1. DoStopDevice()
2. SetFrameBufferPool(nullptr)
3. Issue StopDevice request to Device Thread
6. Receive OnFrame message
Device Thread:
4. Capture frame
5. Issue OnFrame message to IO Thread
7. StopDevice
The fix is to ignore incoming frames when FrameBufferPool is null.
BUG=681836
TEST=
content_unittests --gtest_filter="*Video*"
Apprtc loopback on Debug
[2] https://codereview.chromium.org/2551193002/
[3] https://codereview.chromium.org/2613793007/
[1] https://crash.corp.google.com/browse?q=custom_data.ChromeCrashProto.ptype%3D%27browser%27%20AND%20custom_data.ChromeCrashProto.magic_signature_1.name%3D%27content%3A%3AVideoCaptureController%3A%3ADoNewBufferOnIOThread%27%20AND%20product.name%3D%27Chrome%27&ignore_case=false&enable_rewrite=true&omit_field_name=&omit_field_value=&omit_field_opt=%3D#samplereports:5,productversion:1000
Review-Url: https://codereview.chromium.org/2643463002
Cr-Commit-Position: refs/heads/master@{#444168}
Committed: https://chromium.googlesource.com/chromium/src/+/b00a589e9a0e0fee86866d21e8fcf4991e82b468
Patch Set 1 #
Dependent Patchsets: Messages
Total messages: 14 (10 generated)
|