Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Issue 2805533002: Reland [Mojo Video Capture] Introduce abstraction VideoCaptureSystem (Closed)

Created:
3 years, 8 months ago by chfremer
Modified:
3 years, 8 months ago
Reviewers:
emircan, gab, mcasas, miu
CC:
chromium-reviews, posciak+watch_chromium.org, chfremer+watch_chromium.org, jam, feature-media-reviews_chromium.org, darin-cc_chromium.org, xjz+watch_chromium.org, miu+watch_chromium.org, gab
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Reland [Mojo Video Capture] Introduce abstraction VideoCaptureSystem Link to original CL: https://codereview.chromium.org/2769543002/ PatchSet 1 is state as reviewed previously. PatchSet 2 applies a fix for the issue described below. This was reverted because it caused a test flakiness for test MediaDevicesDispatcherHostTest.GetVideoInputCapabilities on Windows. Analysis of the issue: The CL created a race condition that could cause the test method to exit before the exercise had finished executing. What made the difference is that VideoCaptureSystem::GetDeviceInfosAsync() invoked by VideoCaptureManager now actually runs asynchronous, i.e. it posts invocation of its |result_callback| to the end of a message queue. Before this CL, VideoCaptureManager directly called VideoCaptureDeviceFactory::EnumerateDeviceDescriptors which, despite its asynchronous-looking API invoked its callback synchronously. The test code was relying on this being the case. After the CL, the following bad sequence could happen: 1.) Test calls |host_->GetVideoInputCapabilities()| which eventually kicks of asynchronous work A on the "device thread". 2.) Test method reaches statement |media_stream_manager_->FlushVideoCaptureThreadForTesting()| and blocks until the already posted work A on the device thread finishes. 3.) Work A posts new work B to the device thread. 4.) Work A finishes. 5.) FlushVideoCaptureThreadForTesting() returns and the test method exits before work B has run. Description of fix: The way that the test was waiting for the asynchronous exercise to complete was based on dangerous (and now incorrect) assumptions of how and where the implementation under test internally posts task. The fix is to eliminate these assumptions and, instead, block the test method until the waited-for callback arrives. Original CL description: This CL is supposed to be a pure refactoring. There should be no changes to existing behavior. This is part of a series of CLs with the goal of separating the class VideoCaptureManager from knowledge of things that are going to be private implementation details of the video capture service. The end goal is to have VideoCaptureManager talk to an abstraction that can be implemented by either the video capture Mojo service or the existing (legacy) in-process implementation. Changes in this CL: * Move nested struct VideoCaptureManager::DeviceInfo to struct media::VideoCaptureDeviceInfo. * Create abstraction VideoCaptureSystem and move caching of VideoCaptureDeviceInfo to there. This allows us to use this functionality in both InProcess and MojoService code paths. * Simplify BuildableDeviceCallbacks interface. With the mapping from device_id to descriptor being moved into VideoCaptureSystem, BuildableDeviceCallbacks no longer needs to offer a LookupDeviceDescriptor() method. This CL is part of the Mojo Video Capture work. For the bigger picture, see [1] CL18. BUG=584797 TEST= content_unittests --gtest_filter="*Video*" content_browsertests --gtest_filter="VideoCaptureBrowserTest.*" [1] https://docs.google.com/a/chromium.org/document/d/1Qw7rw1AJy0QHXjha36jZNiEuxsxWslJ_X-zpOhijvI8/edit?usp=sharing Review-Url: https://codereview.chromium.org/2805533002 Cr-Commit-Position: refs/heads/master@{#462916} Committed: https://chromium.googlesource.com/chromium/src/+/8927c43c9dfd0fa73d092eea903f9f3a1f3292f1

Patch Set 1 : State as reviewed previously #

Patch Set 2 : Fix race condition in tests #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+345 lines, -271 lines) Patch
M content/browser/renderer_host/media/buildable_video_capture_device.h View 1 chunk +1 line, -5 lines 0 comments Download
M content/browser/renderer_host/media/in_process_buildable_video_capture_device.h View 4 chunks +4 lines, -4 lines 0 comments Download
M content/browser/renderer_host/media/in_process_buildable_video_capture_device.cc View 7 chunks +17 lines, -45 lines 0 comments Download
M content/browser/renderer_host/media/media_devices_dispatcher_host_unittest.cc View 1 2 chunks +9 lines, -20 lines 3 comments Download
M content/browser/renderer_host/media/media_devices_manager_unittest.cc View 1 chunk +3 lines, -2 lines 0 comments Download
M content/browser/renderer_host/media/media_stream_manager.h View 1 1 chunk +0 lines, -4 lines 0 comments Download
M content/browser/renderer_host/media/media_stream_manager.cc View 1 3 chunks +6 lines, -13 lines 0 comments Download
M content/browser/renderer_host/media/video_capture_manager.h View 7 chunks +16 lines, -28 lines 0 comments Download
M content/browser/renderer_host/media/video_capture_manager.cc View 13 chunks +42 lines, -144 lines 0 comments Download
M content/browser/renderer_host/media/video_capture_manager_unittest.cc View 2 chunks +8 lines, -6 lines 0 comments Download
M media/capture/BUILD.gn View 1 chunk +4 lines, -0 lines 0 comments Download
M media/capture/video/video_capture_device_factory.h View 1 chunk +2 lines, -0 lines 0 comments Download
A media/capture/video/video_capture_device_info.h View 1 chunk +28 lines, -0 lines 0 comments Download
A media/capture/video/video_capture_device_info.cc View 1 chunk +23 lines, -0 lines 0 comments Download
A media/capture/video/video_capture_system.h View 1 chunk +56 lines, -0 lines 0 comments Download
A media/capture/video/video_capture_system.cc View 1 chunk +126 lines, -0 lines 0 comments Download

Dependent Patchsets:

Messages

Total messages: 20 (11 generated)
chfremer
emircan@: PTAL mcasas@, miu@, gab@: FYI
3 years, 8 months ago (2017-04-05 22:46:43 UTC) #5
emircan
lgtm
3 years, 8 months ago (2017-04-05 23:11:08 UTC) #6
gab
On 2017/04/05 22:46:43, chfremer wrote: > emircan@: PTAL > mcasas@, miu@, gab@: FYI Curious why ...
3 years, 8 months ago (2017-04-06 16:10:45 UTC) #9
gab
On 2017/04/06 16:10:45, gab wrote: > On 2017/04/05 22:46:43, chfremer wrote: > > emircan@: PTAL ...
3 years, 8 months ago (2017-04-06 17:09:09 UTC) #12
chfremer
On 2017/04/06 17:09:09, gab wrote: > On 2017/04/06 16:10:45, gab wrote: > > On 2017/04/05 ...
3 years, 8 months ago (2017-04-06 17:14:06 UTC) #13
chfremer
https://codereview.chromium.org/2805533002/diff/20001/content/browser/renderer_host/media/media_devices_dispatcher_host_unittest.cc File content/browser/renderer_host/media/media_devices_dispatcher_host_unittest.cc (right): https://codereview.chromium.org/2805533002/diff/20001/content/browser/renderer_host/media/media_devices_dispatcher_host_unittest.cc#newcode360 content/browser/renderer_host/media/media_devices_dispatcher_host_unittest.cc:360: .WillOnce(InvokeWithoutArgs([&run_loop]() { run_loop.Quit(); })); On 2017/04/06 17:09:09, gab wrote: ...
3 years, 8 months ago (2017-04-06 17:19:11 UTC) #14
gab
https://codereview.chromium.org/2805533002/diff/20001/content/browser/renderer_host/media/media_devices_dispatcher_host_unittest.cc File content/browser/renderer_host/media/media_devices_dispatcher_host_unittest.cc (right): https://codereview.chromium.org/2805533002/diff/20001/content/browser/renderer_host/media/media_devices_dispatcher_host_unittest.cc#newcode360 content/browser/renderer_host/media/media_devices_dispatcher_host_unittest.cc:360: .WillOnce(InvokeWithoutArgs([&run_loop]() { run_loop.Quit(); })); On 2017/04/06 17:19:11, chfremer wrote: ...
3 years, 8 months ago (2017-04-06 17:20:24 UTC) #15
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2805533002/20001
3 years, 8 months ago (2017-04-07 16:11:50 UTC) #17
commit-bot: I haz the power
3 years, 8 months ago (2017-04-07 17:46:22 UTC) #20
Message was sent while issue was closed.
Committed patchset #2 (id:20001) as
https://chromium.googlesource.com/chromium/src/+/8927c43c9dfd0fa73d092eea903f...

Powered by Google App Engine
This is Rietveld 408576698