RESOLVED FIXED232737
Add basic support for launching CaptivePortalMode WebProcesses
https://bugs.webkit.org/show_bug.cgi?id=232737
Summary Add basic support for launching CaptivePortalMode WebProcesses
Chris Dumez
Comment 1 2021-11-04 17:09:05 PDT
Chris Dumez
Comment 2 2021-11-04 17:13:09 PDT
Created attachment 443357 [details] WIP Patch
Chris Dumez
Comment 3 2021-11-05 07:57:30 PDT
Created attachment 443392 [details] WIP Patch (with API test)
Chris Dumez
Comment 4 2021-11-05 09:13:18 PDT
Created attachment 443401 [details] WIP Patch
Chris Dumez
Comment 5 2021-11-05 09:29:41 PDT
Brent Fulgham
Comment 6 2021-11-05 09:46:35 PDT
Comment on attachment 443406 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=443406&action=review > Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h:95 > + JSC::Options::Options::useJIT() = false; I think for miniMode we also want: JSC::Options::Options::useGenerationalGC() = false; JSC::Options::Options::useConcurrentGC() = false;
Alexey Proskuryakov
Comment 7 2021-11-05 09:48:39 PDT
The content of attachment 443357 [details] has been deleted
Alexey Proskuryakov
Comment 8 2021-11-05 09:48:48 PDT
The content of attachment 443392 [details] has been deleted
Alexey Proskuryakov
Comment 9 2021-11-05 09:48:58 PDT
The content of attachment 443401 [details] has been deleted
Chris Dumez
Comment 10 2021-11-05 09:57:25 PDT
Tim Horton
Comment 11 2021-11-05 10:57:05 PDT
Comment on attachment 443412 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=443412&action=review > Source/WebKit/UIProcess/WebPageProxy.cpp:3439 > + auto shouldEnableMiniMode = (policies ? policies->miniModeEnabled() : isMiniModeEnabledGlobally()) ? WebProcessProxy::IsMiniModeEnabled::Yes : WebProcessProxy::IsMiniModeEnabled::No; If the global switch is not "force enable mini mode" but instead a /fallback/, why not just use the normal bit on defaultWebpagePreferences in WKWebViewConfiguration?
Chris Dumez
Comment 12 2021-11-05 11:01:53 PDT
Chris Dumez
Comment 13 2021-11-05 11:10:14 PDT
(In reply to Tim Horton from comment #11) > Comment on attachment 443412 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=443412&action=review > > > Source/WebKit/UIProcess/WebPageProxy.cpp:3439 > > + auto shouldEnableMiniMode = (policies ? policies->miniModeEnabled() : isMiniModeEnabledGlobally()) ? WebProcessProxy::IsMiniModeEnabled::Yes : WebProcessProxy::IsMiniModeEnabled::No; > > If the global switch is not "force enable mini mode" but instead a > /fallback/, why not just use the normal bit on defaultWebpagePreferences in > WKWebViewConfiguration? Captive portal mode can be enabled / disabled system wide. Then it can be overridden by browsers per-site via WKWebpagePreferences. The issue with WKWebViewConfiguration.defaultWebpagePreferences.captivePortalModeEnabled is that it only applies to WebViews using this configuration, it is not app-global. Also, when the client is setting captivePortalModeEnabled on a WKWebpagePreferences object, how do I know if I am supposed to set the global NSUserDefault or not? How do I differentiate the case where the client wants to set it globally vs the client wants to set it by default for all views using this WKWebViewConfiguration (or only for this navigation)? This is why I introduced a WKWebpagePreferences._captivePortalModeEnabled class property (readwrite), so that the client can set or query the global state of the feature.
Chris Dumez
Comment 14 2021-11-05 11:34:32 PDT
(In reply to Chris Dumez from comment #13) > (In reply to Tim Horton from comment #11) > > Comment on attachment 443412 [details] > > Patch > > > > View in context: > > https://bugs.webkit.org/attachment.cgi?id=443412&action=review > > > > > Source/WebKit/UIProcess/WebPageProxy.cpp:3439 > > > + auto shouldEnableMiniMode = (policies ? policies->miniModeEnabled() : isMiniModeEnabledGlobally()) ? WebProcessProxy::IsMiniModeEnabled::Yes : WebProcessProxy::IsMiniModeEnabled::No; > > > > If the global switch is not "force enable mini mode" but instead a > > /fallback/, why not just use the normal bit on defaultWebpagePreferences in > > WKWebViewConfiguration? > > Captive portal mode can be enabled / disabled system wide. Then it can be > overridden by browsers per-site via WKWebpagePreferences. > > The issue with > WKWebViewConfiguration.defaultWebpagePreferences.captivePortalModeEnabled is > that it only applies to WebViews using this configuration, it is not > app-global. > > Also, when the client is setting captivePortalModeEnabled on a > WKWebpagePreferences object, how do I know if I am supposed to set the > global NSUserDefault or not? How do I differentiate the case where the > client wants to set it globally vs the client wants to set it by default for > all views using this WKWebViewConfiguration (or only for this navigation)? > > This is why I introduced a WKWebpagePreferences._captivePortalModeEnabled > class property (readwrite), so that the client can set or query the global > state of the feature. After discussing with Tim and Wenson offline, I think we have a simpler proposal. Reworking the patch now..
Chris Dumez
Comment 15 2021-11-05 13:30:55 PDT
Tim Horton
Comment 16 2021-11-05 13:46:29 PDT
Comment on attachment 443431 [details] Patch Not sure about all of the "is" prefixes (also you have both "shouldUse" and "shouldEnable" and I think they have the same meaning?), but this seems better to me.
Chris Dumez
Comment 17 2021-11-05 14:08:11 PDT
Alex Christensen
Comment 18 2021-11-08 16:59:12 PST
Comment on attachment 443435 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=443435&action=review > Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h:100 > JSC::ExecutableAllocator::setJITEnabled(false); This does some stronger things that we may want to do in captive portal mode. We should also audit the users of disable-jit and see if they can migrate to this as a replacement. > Source/WebKit/UIProcess/API/APIWebsitePolicies.h:163 > + std::optional<bool> m_captivePortalModeEnabled; This can just be a bool that defaults to WebKit::captivePortalModeEnabledBySystem(), right? > Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:7630 > +// On iOS, the captive portal mode API requires a browser entitlement. Why don't we give TestWebKitAPI this entitlement to test what happens when you have it?
Chris Dumez
Comment 19 2021-11-08 17:14:16 PST
Comment on attachment 443435 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=443435&action=review >> Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h:100 >> JSC::ExecutableAllocator::setJITEnabled(false); > > This does some stronger things that we may want to do in captive portal mode. > We should also audit the users of disable-jit and see if they can migrate to this as a replacement. > This does some stronger things that we may want to do in captive portal mode. I don't understand this comment. Also, why are you commenting on the pre-existing disable-jit flag. I am not relying on this pre-existing disable-jit flag because we turn off more JSC features in captive portal mode. Also, in a follow-up patch, it will also impact WebCore settings, not just JSC options. >> Source/WebKit/UIProcess/API/APIWebsitePolicies.h:163 >> + std::optional<bool> m_captivePortalModeEnabled; > > This can just be a bool that defaults to WebKit::captivePortalModeEnabledBySystem(), right? The reason I used an std::optional<bool> is that the system setting may change during the lifetime of the APIWebsitePolicies object. If I use a bool and set the value at construction time, then we won't update it if the system setting changes. This is especially problematic for WKWebViewConfiguration.defaultWebpagePreferences which has a long lifetime. >> Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:7630 >> +// On iOS, the captive portal mode API requires a browser entitlement. > > Why don't we give TestWebKitAPI this entitlement to test what happens when you have it? It would be nice, yes. I don't know how to do that yet but I will look into it.
Alex Christensen
Comment 20 2021-11-08 17:16:05 PST
Comment on attachment 443435 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=443435&action=review >>> Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h:100 >>> JSC::ExecutableAllocator::setJITEnabled(false); >> >> This does some stronger things that we may want to do in captive portal mode. >> We should also audit the users of disable-jit and see if they can migrate to this as a replacement. > > I may be wrong, but I think ExecutableAllocator::setJITEnabled makes it so the process is unable to allocate executable memory even if compromised, whereas JSC::Options::useJIT() = false; just makes it so it doesn't try to under normal circumstances.
Chris Dumez
Comment 21 2021-11-08 17:18:00 PST
(In reply to Alex Christensen from comment #20) > Comment on attachment 443435 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=443435&action=review > > >>> Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h:100 > >>> JSC::ExecutableAllocator::setJITEnabled(false); > >> > >> This does some stronger things that we may want to do in captive portal mode. > >> We should also audit the users of disable-jit and see if they can migrate to this as a replacement. > > > > > > I may be wrong, but I think ExecutableAllocator::setJITEnabled makes it so > the process is unable to allocate executable memory even if compromised, > whereas JSC::Options::useJIT() = false; just makes it so it doesn't try to > under normal circumstances. Oh I see. I didn't understand that initially. ExecutableAllocator::setJITEnabled() may be more suitable then, I'll look into it.
Chris Dumez
Comment 22 2021-11-08 17:19:37 PST
Comment on attachment 443435 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=443435&action=review >>>>> Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h:100 >>>>> JSC::ExecutableAllocator::setJITEnabled(false); >>>> >>>> This does some stronger things that we may want to do in captive portal mode. >>>> We should also audit the users of disable-jit and see if they can migrate to this as a replacement. >>> >>> >> >> I may be wrong, but I think ExecutableAllocator::setJITEnabled makes it so the process is unable to allocate executable memory even if compromised, whereas JSC::Options::useJIT() = false; just makes it so it doesn't try to under normal circumstances. > > Oh I see. I didn't understand that initially. ExecutableAllocator::setJITEnabled() may be more suitable then, I'll look into it. If I remember correctly, the reason I used `JSC::Options::useJIT() = false` is that `[webView _isJITEnabled:(void(^)(BOOL))completionHandler]` was returning NO when using `JSC::ExecutableAllocator::setJITEnabled(false)`. This may be an issue with _isJITEnabled not properly detecting that JIT is disable though.
Chris Dumez
Comment 23 2021-11-08 17:52:51 PST
Chris Dumez
Comment 24 2021-11-08 18:37:12 PST
Chris Dumez
Comment 25 2021-11-08 18:38:36 PST
Per Alex's feedback: - Now using `ExecutableAllocator::setJITEnabled(false)` instead of `JSC::Options::Options::useJIT() = false;`. - Also giving the browser entitlement to TestWebKitAPI on iOS so I can enable the API tests on iOS as well.
Chris Dumez
Comment 26 2021-11-10 09:49:24 PST
ping review?
Brent Fulgham
Comment 27 2021-11-10 11:10:17 PST
Comment on attachment 443646 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=443646&action=review r=me > Source/WebKit/UIProcess/API/Cocoa/WKWebpagePreferences.h:74 > +/*! @abstract A boolean indicating whether captive portal mode is enabled. nit: Captive Portal ? > Tools/TestWebKitAPI/Configurations/TestWebKitAPI-iOS.entitlements:14 > + <true/> Nit: Weird whitespace.
Chris Dumez
Comment 28 2021-11-10 11:14:37 PST
Note You need to log in before you can comment on or make changes to this bug.