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

Issue 464363003: Mac QTKit Video Capture: Run QTCaptureSession teardown in UI thread, clean up -stopCapture use. (Closed)

Created:
6 years, 4 months ago by mcasas
Modified:
6 years, 4 months ago
CC:
chromium-reviews, posciak+watch_chromium.org, feature-media-reviews_chromium.org, wjia+watch_chromium.org, mcasas+watch_chromium.org
Project:
chromium
Visibility:
Public.

Description

Mac QTKit Video Capture: Run QTCaptureSession teardown in UI thread, clean up -stopCapture use. It can be read in the code: > 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 In the same spirit, seems that -removeInput: and -stopRunning are being called from a background thread causing deadlocks every now and then. This CL temptatively sends _both_ to be run on UI thread, hence avoiding the potential deadlock. -stopCapture is called from VideoCaptureDeviceMac::StopAndDeAllocate() and then maybe in -setCaptureDevice. Remove the first call and make sure it's always called inside -setCaptureDevice. BUG=399792, 285053 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=291018

Patch Set 1 #

Total comments: 6

Patch Set 2 : shess@ comments #

Total comments: 4

Patch Set 3 : shess@ comments: Moved input/output removal to one place, cleaned up input/output count #

Total comments: 9

Patch Set 4 : shess@ comments, rebased. #

Total comments: 2

Patch Set 5 : shess@ comments on -stopCaptureOnUIThread: #

Unified diffs Side-by-side diffs Delta from patch set Stats (+28 lines, -30 lines) Patch
M media/video/capture/mac/platform_video_capturing_mac.h View 1 2 3 3 chunks +5 lines, -4 lines 0 comments Download
M media/video/capture/mac/video_capture_device_mac.mm View 1 2 1 chunk +0 lines, -1 line 0 comments Download
M media/video/capture/mac/video_capture_device_qtkit_mac.mm View 1 2 3 4 2 chunks +23 lines, -25 lines 0 comments Download

Messages

Total messages: 23 (0 generated)
mcasas
vrk@, rsesek@, PTAL. I would like to get this tested and would not land it ...
6 years, 4 months ago (2014-08-13 16:33:59 UTC) #1
vrk (LEFT CHROMIUM)
lgtm https://codereview.chromium.org/464363003/diff/1/media/video/capture/mac/video_capture_device_qtkit_mac.mm File media/video/capture/mac/video_capture_device_qtkit_mac.mm (right): https://codereview.chromium.org/464363003/diff/1/media/video/capture/mac/video_capture_device_qtkit_mac.mm#newcode247 media/video/capture/mac/video_capture_device_qtkit_mac.mm:247: [self performSelectorOnMainThread:@selector(stopCaptureOnUIThread:) Hmm, when I read the stack ...
6 years, 4 months ago (2014-08-14 02:48:30 UTC) #2
mcasas
shess@ you addressed similar issues before, could you PTAL? https://codereview.chromium.org/464363003/diff/1/media/video/capture/mac/video_capture_device_qtkit_mac.mm File media/video/capture/mac/video_capture_device_qtkit_mac.mm (right): https://codereview.chromium.org/464363003/diff/1/media/video/capture/mac/video_capture_device_qtkit_mac.mm#newcode247 media/video/capture/mac/video_capture_device_qtkit_mac.mm:247: ...
6 years, 4 months ago (2014-08-14 07:23:30 UTC) #3
mcasas
6 years, 4 months ago (2014-08-14 13:24:02 UTC) #4
Robert Sesek
I'll defer to shess@ on this one, since he fought this nasty/crazy stuff before. https://codereview.chromium.org/464363003/diff/1/media/video/capture/mac/video_capture_device_qtkit_mac.mm ...
6 years, 4 months ago (2014-08-14 16:15:43 UTC) #5
Scott Hess - ex-Googler
https://codereview.chromium.org/464363003/diff/1/media/video/capture/mac/video_capture_device_qtkit_mac.mm File media/video/capture/mac/video_capture_device_qtkit_mac.mm (left): https://codereview.chromium.org/464363003/diff/1/media/video/capture/mac/video_capture_device_qtkit_mac.mm#oldcode244 media/video/capture/mac/video_capture_device_qtkit_mac.mm:244: [captureSession_ removeInput:captureDeviceInput_]; As phrased, it's saying "If the number ...
6 years, 4 months ago (2014-08-14 17:35:56 UTC) #6
mcasas
shess@, tommi@ PTAL. https://codereview.chromium.org/464363003/diff/1/media/video/capture/mac/video_capture_device_qtkit_mac.mm File media/video/capture/mac/video_capture_device_qtkit_mac.mm (left): https://codereview.chromium.org/464363003/diff/1/media/video/capture/mac/video_capture_device_qtkit_mac.mm#oldcode244 media/video/capture/mac/video_capture_device_qtkit_mac.mm:244: [captureSession_ removeInput:captureDeviceInput_]; On 2014/08/14 17:35:55, Scott ...
6 years, 4 months ago (2014-08-15 08:49:58 UTC) #7
tommi (sloooow) - chröme
lgtm fwiw - I'm having a hard time wrapping my head around how this works ...
6 years, 4 months ago (2014-08-15 08:58:31 UTC) #8
Scott Hess - ex-Googler
Apologies for lateness, I was trying to accomplish a thing today so was ignoring emails. ...
6 years, 4 months ago (2014-08-15 23:38:16 UTC) #9
mcasas
shess@ PTAL. https://codereview.chromium.org/464363003/diff/80001/media/video/capture/mac/video_capture_device_qtkit_mac.mm File media/video/capture/mac/video_capture_device_qtkit_mac.mm (right): https://codereview.chromium.org/464363003/diff/80001/media/video/capture/mac/video_capture_device_qtkit_mac.mm#newcode239 media/video/capture/mac/video_capture_device_qtkit_mac.mm:239: - (void)stopCapture { On 2014/08/15 23:38:15, Scott ...
6 years, 4 months ago (2014-08-18 11:29:43 UTC) #10
Scott Hess - ex-Googler
LGTM, I'm down to quibbles. The only one I _really_ care about is -stopCaptureOnUIThread:, so ...
6 years, 4 months ago (2014-08-18 18:23:41 UTC) #11
mcasas
shess@ PTAL https://codereview.chromium.org/464363003/diff/120001/media/video/capture/mac/platform_video_capturing_mac.h File media/video/capture/mac/platform_video_capturing_mac.h (right): https://codereview.chromium.org/464363003/diff/120001/media/video/capture/mac/platform_video_capturing_mac.h#newcode44 media/video/capture/mac/platform_video_capturing_mac.h:44: // Starts video capturing, register observers. Returns ...
6 years, 4 months ago (2014-08-19 15:24:59 UTC) #12
Scott Hess - ex-Googler
https://codereview.chromium.org/464363003/diff/120001/media/video/capture/mac/video_capture_device_qtkit_mac.mm File media/video/capture/mac/video_capture_device_qtkit_mac.mm (right): https://codereview.chromium.org/464363003/diff/120001/media/video/capture/mac/video_capture_device_qtkit_mac.mm#newcode226 media/video/capture/mac/video_capture_device_qtkit_mac.mm:226: // handler might need. To avoid q deadlock, we ...
6 years, 4 months ago (2014-08-19 18:27:50 UTC) #13
mcasas
shess@ PTAL https://codereview.chromium.org/464363003/diff/140001/media/video/capture/mac/video_capture_device_qtkit_mac.mm File media/video/capture/mac/video_capture_device_qtkit_mac.mm (right): https://codereview.chromium.org/464363003/diff/140001/media/video/capture/mac/video_capture_device_qtkit_mac.mm#newcode240 media/video/capture/mac/video_capture_device_qtkit_mac.mm:240: return; On 2014/08/19 18:27:50, Scott Hess wrote: ...
6 years, 4 months ago (2014-08-20 09:08:25 UTC) #14
Scott Hess - ex-Googler
LGTM. Commit before I comment again!
6 years, 4 months ago (2014-08-20 16:56:45 UTC) #15
mcasas
The CQ bit was checked by mcasas@chromium.org
6 years, 4 months ago (2014-08-20 18:45:36 UTC) #16
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/mcasas@chromium.org/464363003/160001
6 years, 4 months ago (2014-08-20 18:46:59 UTC) #17
commit-bot: I haz the power
FYI, CQ is re-trying this CL (attempt #1). The failing builders are: android_clang_dbg on tryserver.chromium.linux ...
6 years, 4 months ago (2014-08-20 19:55:53 UTC) #18
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 4 months ago (2014-08-20 20:01:00 UTC) #19
commit-bot: I haz the power
Try jobs failed on following builders: android_clang_dbg on tryserver.chromium.linux (http://build.chromium.org/p/tryserver.chromium.linux/builders/android_clang_dbg/builds/7846)
6 years, 4 months ago (2014-08-20 20:01:01 UTC) #20
mcasas
The CQ bit was checked by mcasas@chromium.org
6 years, 4 months ago (2014-08-21 06:58:28 UTC) #21
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/mcasas@chromium.org/464363003/160001
6 years, 4 months ago (2014-08-21 06:59:56 UTC) #22
commit-bot: I haz the power
6 years, 4 months ago (2014-08-21 08:00:57 UTC) #23
Message was sent while issue was closed.
Committed patchset #5 (160001) as 291018

Powered by Google App Engine
This is Rietveld 408576698