Bug 188704 - [GTK][WPE] Make sure MediaDeviceEnabled and PeerConnectionEnabled are always synced with enable-media-stream
Summary: [GTK][WPE] Make sure MediaDeviceEnabled and PeerConnectionEnabled are always ...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Thibault Saunier
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-08-17 12:02 PDT by Thibault Saunier
Modified: 2018-09-20 13:48 PDT (History)
8 users (show)

See Also:


Attachments
Patch (1.91 KB, patch)
2018-08-17 12:06 PDT, Thibault Saunier
no flags Details | Formatted Diff | Diff
Patch (1.80 KB, patch)
2018-08-20 05:36 PDT, Thibault Saunier
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews102 for mac-sierra (2.34 MB, application/zip)
2018-08-20 06:41 PDT, EWS Watchlist
no flags Details
Patch for landing (1.82 KB, patch)
2018-09-20 13:10 PDT, Thibault Saunier
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thibault Saunier 2018-08-17 12:02:05 PDT
[GTK][WPE] Make sure MediaDeviceEnabled and PeerConnectionEnabled are always synced with enable-media-stream
Comment 1 Thibault Saunier 2018-08-17 12:06:01 PDT
Created attachment 347376 [details]
Patch
Comment 2 EWS Watchlist 2018-08-17 12:07:42 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 3 Michael Catanzaro 2018-08-17 15:58:30 PDT
Comment on attachment 347376 [details]
Patch

If the previous value was enabled, and the other settings were not already enabled, there is a bug. If the previous value was disabled, and the other settings were not already disabled, there is another bug.

Looks to me like the problem here was the initial states of these settings, which should be addressed by changing the default values of the member variables, right?

Might also be worth considering whether it makes sense to have three different settings here.
Comment 4 Thibault Saunier 2018-08-17 17:14:05 PDT
Those a(In reply to Michael Catanzaro from comment #3)
> Comment on attachment 347376 [details]
> Patch
> 
> If the previous value was enabled, and the other settings were not already
> enabled, there is a bug. If the previous value was disabled, and the other
> settings were not already disabled, there is another bug.
> 
> Looks to me like the problem here was the initial states of these settings,
> which should be addressed by changing the default values of the member
> variables, right?

Those are the defaults in RuntimeEnabledFeatures.h:

```
#if ENABLE(MEDIA_STREAM)
    bool m_isMediaDevicesEnabled { false };
    bool m_isMediaStreamEnabled { true };
    bool m_isScreenCaptureEnabled { false };
#endif
``` 

> Might also be worth considering whether it makes sense to have three
> different settings here.

It is API now?
Comment 5 Michael Catanzaro 2018-08-18 07:32:36 PDT
(In reply to Thibault Saunier from comment #4) 
> Those are the defaults in RuntimeEnabledFeatures.h:
> 
> ```
> #if ENABLE(MEDIA_STREAM)
>     bool m_isMediaDevicesEnabled { false };
>     bool m_isMediaStreamEnabled { true };
>     bool m_isScreenCaptureEnabled { false };
> #endif
> ``` 

If they only need to be synced at the GLib API layer, then I would do it in WebKitSettings's constructed function.

> > Might also be worth considering whether it makes sense to have three
> > different settings here.
> 
> It is API now?

There are two ways to read your question:

(a) Is it an API guarantee that webkit_settings_set_enable_media_stream() should also call setMediaDevicesEnabled() and setPeerConnectionEnabled()? No it is not, because webkit_settings_set_enable_media_stream() has never done anything in releases, because media stream has been disabled at build time in every release we have ever made. We've never even made a release with libwebrtc included. So no, we can change its behavior however we want without breaking anything. (Adding this function to the API before it was ready was a huge mistake that we should not repeat. It's very confusing to have API functions that do nothing, especially when the documentation doesn't indicate that at all. And it's been like this for four years now.)

(b) Are the setMediaDevicesEnabled/setMediaStreamEnabled/setPeerConnectionEnabled  themselves API? I see mediaDevicesEnabled exposed in WKPreferencesPrivate.h, which tells me it's private for Cocoa (used only by the TestRunner). Same for mediaStreamEnabled and screenCaptureEnabled. Unless I'm missing something, I think we can change it as desired. Don't be confused by WKPreferencesRef.h: the C API is also private API for the TestRunner. Only the Cocoa and GLib APIs are public.

So we should consider:

 * Merging the three internal settings together, if it makes sense to have only one exposed in the public API
 * Or making the other two settings public, if it makes sense to have all three internally

as avoiding mismatch between the public and internal settings is desirable.

But anyway, you don't have to do any of that in this bug, or even at all. It's just an idle thought.
Comment 6 Thibault Saunier 2018-08-18 08:14:30 PDT
`enable-media-stream` is a Construct property, so basically here I am guaranteeing that properties are in sync at construct time, even though lower might decide otherwise.

To me having 3 settings is overkill and having 1 is enough.
Comment 7 Michael Catanzaro 2018-08-18 09:34:03 PDT
(In reply to Thibault Saunier from comment #6)
> `enable-media-stream` is a Construct property, so basically here I am
> guaranteeing that properties are in sync at construct time, even though
> lower might decide otherwise.

TBH I don't understand your argument. Removing the early return is not good. I understand that it works here since it gets called at construct time, but it would be much better to be explicit and sync the settings in constructed instead.

That will also avoid the future situation where somebody notices the early return is missing and adds it back.
Comment 8 Thibault Saunier 2018-08-20 05:36:17 PDT
Created attachment 347492 [details]
Patch
Comment 9 Thibault Saunier 2018-08-20 05:43:16 PDT
(In reply to Thibault Saunier from comment #8)
> Created attachment 347492 [details]
> Patch

Just did what you asked for, makes sense indeed.
Comment 10 EWS Watchlist 2018-08-20 06:41:03 PDT
Comment on attachment 347492 [details]
Patch

Attachment 347492 [details] did not pass mac-ews (mac):
Output: https://webkit-queues.webkit.org/results/8916583

New failing tests:
fetch/fetch-worker-crash.html
Comment 11 EWS Watchlist 2018-08-20 06:41:04 PDT
Created attachment 347493 [details]
Archive of layout-test-results from ews102 for mac-sierra

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102  Port: mac-sierra  Platform: Mac OS X 10.12.6
Comment 12 Thibault Saunier 2018-08-20 06:52:11 PDT
Unrelated issue?
Comment 13 Michael Catanzaro 2018-08-20 07:20:47 PDT
yes
Comment 14 Thibault Saunier 2018-09-20 13:10:40 PDT
Created attachment 350252 [details]
Patch for landing
Comment 15 WebKit Commit Bot 2018-09-20 13:47:37 PDT
Comment on attachment 350252 [details]
Patch for landing

Clearing flags on attachment: 350252

Committed r236279: <https://trac.webkit.org/changeset/236279>
Comment 16 WebKit Commit Bot 2018-09-20 13:47:38 PDT
All reviewed patches have been landed.  Closing bug.
Comment 17 Radar WebKit Bug Importer 2018-09-20 13:48:23 PDT
<rdar://problem/44653748>