Make sure our calls to AVCaptureDevice requestAccessForMediaType do processing on the main thread
Created attachment 409691 [details] Patch
Created attachment 409692 [details] Patch
Created attachment 409693 [details] Patch
Created attachment 409694 [details] Patch
<rdar://problem/69572304>
Comment on attachment 409694 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=409694&action=review > Source/WebKit/ChangeLog:8 > + The completion handler to [AVCaptureDeviceClass requestAccessForMediaType:] may sometimes be called in a background thread on iOS. Can we make a test for this that will fail on iOS? > Source/WebKit/UIProcess/Cocoa/UIDelegate.mm:995 > + auto completionHandler = [this, weakThis = WTFMove(weakThis), frame = WTFMove(frame), protectedRequest = WTFMove(protectedRequest), webView = WTFMove(webView), topLevelOrigin = WTFMove(topLevelOrigin)](BOOL authorized) { I think it’s a bad pattern when we pass a pointer twice, once that we use and other for lifetime checking. In case like this, can we *not* capture this, please? Minimizes the chance we use it wrong. I feel the same way about capturing both "this" and "protectedThis".
(In reply to Darin Adler from comment #6) > Comment on attachment 409694 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=409694&action=review > > > Source/WebKit/ChangeLog:8 > > + The completion handler to [AVCaptureDeviceClass requestAccessForMediaType:] may sometimes be called in a background thread on iOS. > > Can we make a test for this that will fail on iOS? We are only calling this code path in case the authorisation is undetermined, which will most probably trigger a prompt. We usually avoid doing so as we cannot handle prompts easily. That said, it seems we could investigate using some additional tools. I filed rdar://problem/69687122. > > > Source/WebKit/UIProcess/Cocoa/UIDelegate.mm:995 > > + auto completionHandler = [this, weakThis = WTFMove(weakThis), frame = WTFMove(frame), protectedRequest = WTFMove(protectedRequest), webView = WTFMove(webView), topLevelOrigin = WTFMove(topLevelOrigin)](BOOL authorized) { > > I think it’s a bad pattern when we pass a pointer twice, once that we use > and other for lifetime checking. In case like this, can we *not* capture > this, please? Minimizes the chance we use it wrong. I feel the same way > about capturing both "this" and "protectedThis". Will change it. I agree for weakThis, since 'this' is unsafer than using weakThis. Not sure about protectedThis though. This is no different from using 'this' in a method where this is a protectedThis before.
> > > Source/WebKit/ChangeLog:8 > > > + The completion handler to [AVCaptureDeviceClass requestAccessForMediaType:] may sometimes be called in a background thread on iOS. > > > > Can we make a test for this that will fail on iOS? > > We are only calling this code path in case the authorisation is > undetermined, which will most probably trigger a prompt. > We usually avoid doing so as we cannot handle prompts easily. > That said, it seems we could investigate using some additional tools. > I filed rdar://problem/69687122. Or we could add some testing API to force explicit request.
Created attachment 409875 [details] Patch for landing
Committed r267698: <https://trac.webkit.org/changeset/267698> All reviewed patches have been landed. Closing bug and clearing flags on attachment 409875 [details].