Bug 216872 - Introduce WKWebViewConfiguration mediaCaptureEnabled
Summary: Introduce WKWebViewConfiguration mediaCaptureEnabled
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebRTC (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-09-23 05:02 PDT by youenn fablet
Modified: 2020-09-25 04:59 PDT (History)
5 users (show)

See Also:


Attachments
Patch (20.62 KB, patch)
2020-09-23 05:05 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (21.40 KB, patch)
2020-09-23 05:32 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (23.43 KB, patch)
2020-09-23 08:25 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (22.19 KB, patch)
2020-09-25 02:45 PDT, youenn fablet
no flags Details | Formatted Diff | Diff
Patch for landing (22.23 KB, patch)
2020-09-25 04:12 PDT, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description youenn fablet 2020-09-23 05:02:21 PDT
Introduce WKWebViewConfiguration mediaDevicesEnabled
Comment 1 youenn fablet 2020-09-23 05:05:33 PDT
Created attachment 409463 [details]
Patch
Comment 2 youenn fablet 2020-09-23 05:32:05 PDT
Created attachment 409465 [details]
Patch
Comment 3 Sam Weinig 2020-09-23 07:39:00 PDT
Comment on attachment 409465 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=409465&action=review

> Source/WebKit/ChangeLog:11
> +        Add a new boolean configuration to enable/disable mediaDevices exposure.
> +        Value is off by default.
> +        A future patch will remove the WebPreferences based API, given there is no need
> +        to enable/disable mediaDevices throughout the course of a page.

Can you explain a bit more about why you are moving this? Most feature enablement is currently done through the preferences mechanism, so having this one be on the configuration seems odd and inconsistent. 

If there is new thought process around this, it would be good to have that articulated so we can start the process of migrating everything.
Comment 4 youenn fablet 2020-09-23 07:52:03 PDT
(In reply to Sam Weinig from comment #3)
> Comment on attachment 409465 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=409465&action=review
> 
> > Source/WebKit/ChangeLog:11
> > +        Add a new boolean configuration to enable/disable mediaDevices exposure.
> > +        Value is off by default.
> > +        A future patch will remove the WebPreferences based API, given there is no need
> > +        to enable/disable mediaDevices throughout the course of a page.
> 
> Can you explain a bit more about why you are moving this? Most feature
> enablement is currently done through the preferences mechanism, so having
> this one be on the configuration seems odd and inconsistent. 

I am not sure how much this is inconsistent.
There is not much API available in WKPreferences.h.
There are some precedents in WKWebViewConfiguration.h, like allowsAirPlayForMediaPlayback.

> If there is new thought process around this, it would be good to have that
> articulated so we can start the process of migrating everything.

WebPreferences can be changed during the lifetime of the page.
This can be useful, say you want to enable/disable mock devices.

In that particular case, I see no use case for enabling/disabling this setting during the lifetime of the page. There are some downsides of allowing it (some contexts may have navigator.mediaDevices, some may not).
It seems best to enforce a fixed setting hence the idea to move it to WKWebViewConfiguration.
Wdyt?
Comment 5 Alex Christensen 2020-09-23 08:11:36 PDT
Comment on attachment 409465 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=409465&action=review

> Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm:172
> +    BOOL _mediaDevicesEnabled;

This should go on API::PageConfiguration instead.

> Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:123
> +@property (nonatomic, setter=_setMediaDevicesEnabled:) BOOL _mediaDevicesEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));

Could you deprecate the preference SPI with this as a replacement?
Comment 6 youenn fablet 2020-09-23 08:20:45 PDT
(In reply to Alex Christensen from comment #5)
> Comment on attachment 409465 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=409465&action=review
> 
> > Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm:172
> > +    BOOL _mediaDevicesEnabled;
> 
> This should go on API::PageConfiguration instead.

OK.

> > Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h:123
> > +@property (nonatomic, setter=_setMediaDevicesEnabled:) BOOL _mediaDevicesEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
> 
> Could you deprecate the preference SPI with this as a replacement?

Sure, I plan to remove the preference SPI as a follow-up though.
Comment 7 youenn fablet 2020-09-23 08:25:59 PDT
Created attachment 409475 [details]
Patch
Comment 8 Radar WebKit Bug Importer 2020-09-23 09:41:54 PDT
<rdar://problem/69440832>
Comment 9 Sam Weinig 2020-09-23 09:44:54 PDT
(In reply to youenn fablet from comment #4)
> (In reply to Sam Weinig from comment #3)
> > Comment on attachment 409465 [details]
> > Patch
> > 
> > View in context:
> > https://bugs.webkit.org/attachment.cgi?id=409465&action=review
> > 
> > > Source/WebKit/ChangeLog:11
> > > +        Add a new boolean configuration to enable/disable mediaDevices exposure.
> > > +        Value is off by default.
> > > +        A future patch will remove the WebPreferences based API, given there is no need
> > > +        to enable/disable mediaDevices throughout the course of a page.
> > 
> > Can you explain a bit more about why you are moving this? Most feature
> > enablement is currently done through the preferences mechanism, so having
> > this one be on the configuration seems odd and inconsistent. 
> 
> I am not sure how much this is inconsistent.
> There is not much API available in WKPreferences.h.
> There are some precedents in WKWebViewConfiguration.h, like
> allowsAirPlayForMediaPlayback.

The preferences expose all the preferences set in the WebPreferences*.yaml files. There are a ton of them. They don't each necessarily get their own corresponding WKPreferences API call site, but most can accessed via the enumerations for internal debug or experimental features accessors. 

> 
> > If there is new thought process around this, it would be good to have that
> > articulated so we can start the process of migrating everything.
> 
> WebPreferences can be changed during the lifetime of the page.
> This can be useful, say you want to enable/disable mock devices.
> 
> In that particular case, I see no use case for enabling/disabling this
> setting during the lifetime of the page. There are some downsides of
> allowing it (some contexts may have navigator.mediaDevices, some may not).
> It seems best to enforce a fixed setting hence the idea to move it to
> WKWebViewConfiguration.
> Wdyt?

It's hard to judge as I don't know what your intended use case for this is. Who is the target audience of this SPI?
Comment 10 Radar WebKit Bug Importer 2020-09-23 09:45:31 PDT
<rdar://problem/69441004>
Comment 11 youenn fablet 2020-09-23 10:10:11 PDT
> > In that particular case, I see no use case for enabling/disabling this
> > setting during the lifetime of the page. There are some downsides of
> > allowing it (some contexts may have navigator.mediaDevices, some may not).
> > It seems best to enforce a fixed setting hence the idea to move it to
> > WKWebViewConfiguration.
> > Wdyt?
> 
> It's hard to judge as I don't know what your intended use case for this is.
> Who is the target audience of this SPI?

Goal is not to stay at SPI.
Comment 12 Alex Christensen 2020-09-23 13:05:47 PDT
Comment on attachment 409475 [details]
Patch

Actually, we may want to put this on WKWebpagePreferences.
Comment 13 Alex Christensen 2020-09-23 13:41:00 PDT
Comment on attachment 409475 [details]
Patch

The WKUIDelegate needs to give permission, and that can be per-site.  This is great.
Comment 14 youenn fablet 2020-09-24 11:31:19 PDT
We might want to rename mediaDevicesEnabled to mediaCaptureEnabled which intent is clearer.
Comment 15 youenn fablet 2020-09-25 02:45:12 PDT
Created attachment 409676 [details]
Patch for landing
Comment 16 youenn fablet 2020-09-25 04:12:16 PDT
Created attachment 409678 [details]
Patch for landing
Comment 17 EWS 2020-09-25 04:49:02 PDT
Committed r267563: <https://trac.webkit.org/changeset/267563>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 409678 [details].
Comment 18 youenn fablet 2020-09-25 04:59:34 PDT
Removing preference in https://bugs.webkit.org/show_bug.cgi?id=216970