RESOLVED FIXED 192793
Add a new SPI for controlling getUserMedia
https://bugs.webkit.org/show_bug.cgi?id=192793
Summary Add a new SPI for controlling getUserMedia
youenn fablet
Reported 2018-12-17 18:55:28 PST
Add a new SPI for controlling getUserMedia
Attachments
Patch (43.77 KB, patch)
2018-12-18 11:01 PST, youenn fablet
no flags
Patch (48.26 KB, patch)
2018-12-18 11:39 PST, youenn fablet
no flags
Patch (51.61 KB, patch)
2018-12-18 13:40 PST, youenn fablet
no flags
Patch (51.68 KB, patch)
2018-12-18 17:28 PST, youenn fablet
no flags
Patch (54.20 KB, patch)
2018-12-19 14:52 PST, youenn fablet
no flags
Patch (48.66 KB, patch)
2018-12-19 16:00 PST, youenn fablet
no flags
Patch (52.94 KB, patch)
2018-12-20 14:42 PST, youenn fablet
no flags
Patch (53.05 KB, patch)
2018-12-20 15:54 PST, youenn fablet
no flags
Patch (53.70 KB, patch)
2019-01-08 13:33 PST, youenn fablet
no flags
Patch (53.91 KB, patch)
2019-01-08 16:06 PST, youenn fablet
no flags
Patch (55.96 KB, patch)
2019-01-16 13:16 PST, youenn fablet
no flags
Patch for landing (55.13 KB, patch)
2019-01-16 14:54 PST, youenn fablet
no flags
Patch for landing (55.13 KB, patch)
2019-01-16 16:06 PST, youenn fablet
no flags
youenn fablet
Comment 1 2018-12-18 11:01:25 PST
youenn fablet
Comment 2 2018-12-18 11:39:55 PST
youenn fablet
Comment 3 2018-12-18 13:40:18 PST
youenn fablet
Comment 4 2018-12-18 17:28:34 PST
Alex Christensen
Comment 5 2018-12-19 13:02:03 PST
Comment on attachment 357639 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=357639&action=review > Source/WebKit/UIProcess/Cocoa/UIDelegate.mm:862 > auto decisionHandler = makeBlockPtr([protectedRequest = makeRef(request)](BOOL authorized) { This needs a CompletionHandlerCallChecker > Source/WebKit/UIProcess/Cocoa/UIDelegate.mm:996 > + auto decisionHandler = makeBlockPtr([protectedRequest = makeRef(request)](BOOL authorized) { ditto
Eric Carlson
Comment 6 2018-12-19 13:14:16 PST
Comment on attachment 357639 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=357639&action=review > Source/WebKit/ChangeLog:16 > + Did some refactoring by making the callbacks not returning false. Nit: s/not returning false/not return bool/
youenn fablet
Comment 7 2018-12-19 14:52:48 PST
youenn fablet
Comment 8 2018-12-19 16:00:37 PST
youenn fablet
Comment 9 2018-12-20 14:42:34 PST
youenn fablet
Comment 10 2018-12-20 15:54:09 PST
youenn fablet
Comment 11 2019-01-08 13:33:37 PST
Alex Christensen
Comment 12 2019-01-08 14:52:59 PST
Comment on attachment 358631 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=358631&action=review > Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h:111 > +- (void)_webView:(WKWebView *)webView requestMediaCaptureAuthorization:(_WKCaptureDevices)devices decisionHandler:(void (^)(BOOL authorized))decisionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > +- (void)_webView:(WKWebView *)webView isMediaCaptureAuthorized:(void (^)(_WKCaptureDevices authorizedDevices))decisionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); I don't think it is a good design to have two callbacks that are this similar asking a very similar question. It requires app developers to know lots of details about the implementation and set up a finite state machine in a certain way.
Alex Christensen
Comment 13 2019-01-08 15:23:10 PST
We discussed this, and I think it would be much more clear if one callback indicated it was for getUserMedia and one callback was for enumerateDevices.
youenn fablet
Comment 14 2019-01-08 15:51:03 PST
Yes, we can improve the name of the second callback to tie it more to enumerateDevices. Something like canExposeMediaCaptureDeviceInformation for instance.
youenn fablet
Comment 15 2019-01-08 16:06:21 PST
youenn fablet
Comment 16 2019-01-08 16:07:16 PST
(In reply to youenn fablet from comment #15) > Created attachment 358647 [details] > Patch I went with the following name: queryExposableMediaCaptureDeviceInformation
Eric Carlson
Comment 17 2019-01-09 23:03:24 PST
(In reply to Alex Christensen from comment #12) > Comment on attachment 358631 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=358631&action=review > > > Source/WebKit/UIProcess/API/Cocoa/WKUIDelegatePrivate.h:111 > > +- (void)_webView:(WKWebView *)webView requestMediaCaptureAuthorization:(_WKCaptureDevices)devices decisionHandler:(void (^)(BOOL authorized))decisionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > > +- (void)_webView:(WKWebView *)webView isMediaCaptureAuthorized:(void (^)(_WKCaptureDevices authorizedDevices))decisionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); > > I don't think it is a good design to have two callbacks that are this > similar asking a very similar question. I don't agree that the questions are all that similar. One says: Ask the user to see if the page can access data from the camera/microphone right now the other says: Has this user given permission to access camera/microphone without a prompt at some time in the future? > It requires app developers to know lots of details about the > implementation and set up a finite state machine in a certain way. I don't understand this, why does the app need a FSM? In the first case the app prompts the user, and in the second case it checks for a stored setting.
Eric Carlson
Comment 18 2019-01-09 23:10:13 PST
(In reply to Alex Christensen from comment #13) > We discussed this, and I think it would be much more clear if one callback > indicated it was for getUserMedia and one callback was for enumerateDevices. One callback is not just for enumerateDevices. (In reply to youenn fablet from comment #16) > (In reply to youenn fablet from comment #15) > > Created attachment 358647 [details] > > Patch > > I went with the following name: queryExposableMediaCaptureDeviceInformation I agree that the original name can be improved, but I don't think this name is right either. This callback is not just asking about what should be exposed by enumerateDevices, it is asking if the user has given permission to access camera/microphone without a prompt. We may *also* use this to expose device IDs etc before gUM has been called, but it is not the only use of the information provided by this callback. How about -[_webView:hasPermissionToCaptureWithoutUserPrompt:]?
youenn fablet
Comment 19 2019-01-10 08:22:54 PST
> I agree that the original name can be improved, but I don't think this name > is right either. This callback is not just asking about what should be > exposed by enumerateDevices, it is asking if the user has given permission > to access camera/microphone without a prompt. We may *also* use this to > expose device IDs etc before gUM has been called, but it is not the only use > of the information provided by this callback. > > How about -[_webView:hasPermissionToCaptureWithoutUserPrompt:]? Currently, we are only using the second callback to control enumerateDevices. A callback dedicated to enumerateDevices has some benefits: - This offers the flexibility so that one can implement Chrome, Firefox or Safari enumerateDevices behavior - This makes it clear to developers which callback they should implement to allow/disallow getUserMedia. Otherwise, developers might implement "hasPermissionToCaptureWithoutUserPrompt", return yes, and getUserMedia call will still fail.
youenn fablet
Comment 20 2019-01-16 13:16:03 PST
Eric Carlson
Comment 21 2019-01-16 14:13:06 PST
Comment on attachment 359296 [details] Patch r=me with the completion handler change we discussed in person.
youenn fablet
Comment 22 2019-01-16 14:54:38 PST
Created attachment 359314 [details] Patch for landing
youenn fablet
Comment 23 2019-01-16 15:21:56 PST
(In reply to Eric Carlson from comment #21) > Comment on attachment 359296 [details] > Patch > > r=me with the completion handler change we discussed in person. Thanks for the review. Yes, I updated the default implementation accordingly.
WebKit Commit Bot
Comment 24 2019-01-16 15:51:17 PST
Comment on attachment 359314 [details] Patch for landing Rejecting attachment 359314 [details] from commit-queue. Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-03', 'validate-changelog', '--check-oops', '--non-interactive', 359314, '--port=mac']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit ChangeLog entry in Source/WebKit/ChangeLog contains OOPS!. Full output: https://webkit-queues.webkit.org/results/10777103
youenn fablet
Comment 25 2019-01-16 16:06:45 PST
Created attachment 359331 [details] Patch for landing
WebKit Commit Bot
Comment 26 2019-01-16 17:18:11 PST
Comment on attachment 359331 [details] Patch for landing Clearing flags on attachment: 359331 Committed r240100: <https://trac.webkit.org/changeset/240100>
WebKit Commit Bot
Comment 27 2019-01-16 17:18:13 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 28 2019-01-16 17:19:47 PST
Note You need to log in before you can comment on or make changes to this bug.