diff options
author | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-10 00:00:11 +0000 |
---|---|---|
committer | shess@chromium.org <shess@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-10-10 00:00:11 +0000 |
commit | ae966fa3a4f8ce5ef6606960fc1c188df6fb24e0 (patch) | |
tree | a8a11d90df973a6f68df1a45c7b9fc7997fad3a2 /media/video | |
parent | d0a9d157afbe3c2783e2d99b316df007d47df675 (diff) | |
download | chromium_src-ae966fa3a4f8ce5ef6606960fc1c188df6fb24e0.zip chromium_src-ae966fa3a4f8ce5ef6606960fc1c188df6fb24e0.tar.gz chromium_src-ae966fa3a4f8ce5ef6606960fc1c188df6fb24e0.tar.bz2 |
[Mac] Remove webcam capture output on main thread to OS race.
When doing webcam setup and teardown on a background thread, QTKit
appears to have a race condition around how it posts work to the main
thread. This posts part of teardown to the main thread to work around
the problem.
BUG=152757
TEST=See bug.
Review URL: https://chromiumcodereview.appspot.com/11094031
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@160986 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/video')
-rw-r--r-- | media/video/capture/mac/video_capture_device_qtkit_mac.mm | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/media/video/capture/mac/video_capture_device_qtkit_mac.mm b/media/video/capture/mac/video_capture_device_qtkit_mac.mm index c2d2b06..6427f18 100644 --- a/media/video/capture/mac/video_capture_device_qtkit_mac.mm +++ b/media/video/capture/mac/video_capture_device_qtkit_mac.mm @@ -100,9 +100,21 @@ } if ([[captureSession_ outputs] count] > 0) { // Only one output is set for |captureSession_|. - [[[captureSession_ outputs] objectAtIndex:0] setDelegate:nil]; - [captureSession_ removeOutput: - [[captureSession_ outputs] objectAtIndex:0]]; + id output = [[captureSession_ outputs] objectAtIndex:0]; + [output setDelegate:nil]; + + // TODO(shess): QTKit achieves thread safety by posting messages + // to the main thread. As part of -addOutput:, it posts a + // message to the main thread which in turn posts a notification + // which will run in a future spin after the original method + // returns. -removeOutput: can post a main-thread message in + // between while holding a lock which the notification handler + // will need. Posting either -addOutput: or -removeOutput: to + // the main thread should fix it, remove is likely safer. + // http://crbug.com/152757 + [captureSession_ performSelectorOnMainThread:@selector(removeOutput:) + withObject:output + waitUntilDone:YES]; } [captureSession_ release]; captureSession_ = nil; |