RESOLVED FIXED 164760
[MediaStream] Don't request user permission for a device if it has already been granted in the current browsing context
https://bugs.webkit.org/show_bug.cgi?id=164760
Summary [MediaStream] Don't request user permission for a device if it has already be...
Eric Carlson
Reported 2016-11-14 19:39:27 PST
Do not prompt the user for permission to use a capture device if permission has already granted access for the current browsing context.
Attachments
Proposed patch. (24.16 KB, patch)
2016-11-15 07:24 PST, Eric Carlson
buildbot: commit-queue-
Archive of layout-test-results from ews106 for mac-yosemite-wk2 (969.94 KB, application/zip)
2016-11-15 08:29 PST, Build Bot
no flags
Proposed patch. (22.80 KB, patch)
2016-11-15 08:43 PST, Eric Carlson
youennf: review+
Patch for landing. (47.09 KB, patch)
2016-11-28 10:37 PST, Eric Carlson
commit-queue: commit-queue-
Updated patch for landing. (47.08 KB, patch)
2016-11-28 12:07 PST, Eric Carlson
no flags
Another updated patch for landing. (52.65 KB, patch)
2016-11-29 10:30 PST, Eric Carlson
no flags
Updated patch for landing. (52.64 KB, patch)
2016-11-29 10:43 PST, Eric Carlson
no flags
Radar WebKit Bug Importer
Comment 1 2016-11-14 20:08:42 PST
Eric Carlson
Comment 2 2016-11-15 07:24:30 PST
Created attachment 294834 [details] Proposed patch.
Build Bot
Comment 3 2016-11-15 08:29:04 PST
Comment on attachment 294834 [details] Proposed patch. Attachment 294834 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/2520184 New failing tests: fast/mediastream/MediaStream-MediaElement-srcObject.html
Build Bot
Comment 4 2016-11-15 08:29:07 PST
Created attachment 294837 [details] Archive of layout-test-results from ews106 for mac-yosemite-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews106 Port: mac-yosemite-wk2 Platform: Mac OS X 10.10.5
Eric Carlson
Comment 5 2016-11-15 08:43:53 PST
Created attachment 294838 [details] Proposed patch.
youenn fablet
Comment 6 2016-11-15 14:39:08 PST
Comment on attachment 294838 [details] Proposed patch. View in context: https://bugs.webkit.org/attachment.cgi?id=294838&action=review > Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp:51 > + if (deviceUID.isEmpty()) Can this case happen? > Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp:72 > + } while (0); Is it left-over code, or were you planning to add something like ASSERT(!securityOriginsAreEqual(request))? > Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp:81 > + if (!m_userMediaDocumentSecurityOrigin || !m_userMediaDocumentSecurityOrigin->equal(request.userMediaDocumentSecurityOrigin())) I am unclear whether SecurityOrigin::equal is the right routine to call, in particular the check for m_domainWasSetInDOM. It seems the best choice AFAICS though. > Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp:92 > + state->reset(request); I guess reset and securityOriginsAreEqual could be grouped into one function. > Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp:121 > + Ref<UserMediaPermissionRequestProxy> request = UserMediaPermissionRequestProxy::create(*this, userMediaID, frameID, userMediaDocumentOriginIdentifier, topLevelDocumentOriginIdentifier, audioDeviceUIDs, videoDeviceUIDs); Use auto here. > Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp:256 > auto topLevelOrigin = API::SecurityOrigin::create(SecurityOriginData::fromDatabaseIdentifier(topLevelDocumentOriginIdentifier)->securityOrigin()); userMediaOrigin is a RefPtr I guess while it should be a Ref. That would allow removing the *userMediaOrigin.get() below. > Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp:262 > + for (auto deviceUID : audioDeviceUIDs) { Would "for (const auto&" be more efficient? > Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp:266 > + } I wonder whether this pattern could be done at vector level, something like T* firstMatching(const MatchFunction&) and its const version. > Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.h:40 > + FrameAuthorizationState(UserMediaPermissionRequestProxy&); Should be explicit. > Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.h:41 > + ~FrameAuthorizationState() { } Do we need it? > Source/WebKit2/UIProcess/UserMediaPermissionRequestProxy.cpp:38 > + , m_topLevelDocumentSecurityOrigin(SecurityOriginData::fromDatabaseIdentifier(topLevelDocumentOriginIdentifier)->securityOrigin()) Has this strategy of persistent granting the potential to be reused in other APIs? If so, I would introduce a structure for frameID and origins. That would also reduce the number of passed parameters which might improve readability. > LayoutTests/fast/mediastream/MediaDevices-getUserMedia.html:48 > + // successfully created a stream for the mock audio device. Have we tests that exercice the case of no-persistency? Like the case of equal returning false for obvious reasons (port change) but also non obvious (dom flag I talked above)
Eric Carlson
Comment 7 2016-11-28 10:34:02 PST
Comment on attachment 294838 [details] Proposed patch. View in context: https://bugs.webkit.org/attachment.cgi?id=294838&action=review >> Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp:51 >> + if (deviceUID.isEmpty()) > > Can this case happen? Yes, because userMediaAccessWasDenied() is sometimes called before a request is created (e.g. when the UIClient doesn't implement decidePolicyForUserMediaPermissionRequest). >> Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp:72 >> + } while (0); > > Is it left-over code, or were you planning to add something like ASSERT(!securityOriginsAreEqual(request))? I combined reset and securityOriginsAreEqual. >> Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp:92 >> + state->reset(request); > > I guess reset and securityOriginsAreEqual could be grouped into one function. Good idea, fixed. >> Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp:121 >> + Ref<UserMediaPermissionRequestProxy> request = UserMediaPermissionRequestProxy::create(*this, userMediaID, frameID, userMediaDocumentOriginIdentifier, topLevelDocumentOriginIdentifier, audioDeviceUIDs, videoDeviceUIDs); > > Use auto here. Fixed. >> Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp:262 >> + for (auto deviceUID : audioDeviceUIDs) { > > Would "for (const auto&" be more efficient? Fixed. >> Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp:266 >> + } > > I wonder whether this pattern could be done at vector level, something like T* firstMatching(const MatchFunction&) and its const version. I will leave that for another day. >> Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.h:40 >> + FrameAuthorizationState(UserMediaPermissionRequestProxy&); > > Should be explicit. Fixed. >> Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.h:41 >> + ~FrameAuthorizationState() { } > > Do we need it? No, removed. >> LayoutTests/fast/mediastream/MediaDevices-getUserMedia.html:48 >> + // successfully created a stream for the mock audio device. > > Have we tests that exercice the case of no-persistency? > Like the case of equal returning false for obvious reasons (port change) but also non obvious (dom flag I talked above) I modified WTR to track the number of times a gUM call makes it to the UA, and added methods so it can be read and reset from script, and added a test.
Eric Carlson
Comment 8 2016-11-28 10:37:55 PST
Created attachment 295500 [details] Patch for landing.
WebKit Commit Bot
Comment 9 2016-11-28 12:04:42 PST
Comment on attachment 295500 [details] Patch for landing. Rejecting attachment 295500 [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-02', 'validate-changelog', '--check-oops', '--non-interactive', 295500, '--port=mac']" exit_code: 1 cwd: /Volumes/Data/EWS/WebKit ChangeLog entry in LayoutTests/ChangeLog contains OOPS!. Full output: http://webkit-queues.webkit.org/results/2584177
Eric Carlson
Comment 10 2016-11-28 12:07:49 PST
Created attachment 295509 [details] Updated patch for landing.
WebKit Commit Bot
Comment 11 2016-11-28 12:45:30 PST
Comment on attachment 295509 [details] Updated patch for landing. Clearing flags on attachment: 295509 Committed r209008: <http://trac.webkit.org/changeset/209008>
WebKit Commit Bot
Comment 12 2016-11-28 12:45:35 PST
All reviewed patches have been landed. Closing bug.
Ryan Haddad
Comment 13 2016-11-28 14:38:15 PST
(In reply to comment #11) > Comment on attachment 295509 [details] > Updated patch for landing. > > Clearing flags on attachment: 295509 > > Committed r209008: <http://trac.webkit.org/changeset/209008> This change appears to have caused two fast/mediastream test issues: Failure: fast/mediastream/MediaDevices-getUserMedia.html Timeout: fast/mediastream/delayed-permission-allowed.html https://build.webkit.org/results/Apple%20El%20Capitan%20Release%20WK2%20(Tests)/r209012%20(11295)/results.html
Ryan Haddad
Comment 14 2016-11-28 14:41:43 PST
Reverted r209008 for reason: This change appears to have caused two fast/mediastrem LayoutTests to fail. Committed r209024: <http://trac.webkit.org/changeset/209024>
Eric Carlson
Comment 15 2016-11-29 10:30:26 PST
Created attachment 295605 [details] Another updated patch for landing.
Eric Carlson
Comment 16 2016-11-29 10:43:02 PST
Created attachment 295606 [details] Updated patch for landing.
WebKit Commit Bot
Comment 17 2016-11-29 11:20:27 PST
Comment on attachment 295606 [details] Updated patch for landing. Clearing flags on attachment: 295606 Committed r209082: <http://trac.webkit.org/changeset/209082>
WebKit Commit Bot
Comment 18 2016-11-29 11:20:33 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.