Skip to content

Commit

Permalink
Deprecate WKContextSetCustomWebContentServiceBundleIdentifier
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=254699

Reviewed by Geoffrey Garen.

It was introduced as an experiment in Safari that was only fruitful in telling us
that we did not want to proceed.  I am removing that experiment to clean up the process
launcher to have a finite and known set of processes it launches.  The day may come
when we want to redo the experiment, but the process launcher will look significantly
different by then, and we will need to redo it from scratch anyways.

* Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp:
(API::ProcessPoolConfiguration::copy):
* Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h:
* Source/WebKit/UIProcess/API/C/WKContext.cpp:
(WKContextSetCustomWebContentServiceBundleIdentifier):
* Source/WebKit/UIProcess/API/C/WKContext.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
* Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
(-[_WKProcessPoolConfiguration customWebContentServiceBundleIdentifier]):
(-[_WKProcessPoolConfiguration setCustomWebContentServiceBundleIdentifier:]):
* Source/WebKit/UIProcess/Launcher/ProcessLauncher.h:
* Source/WebKit/UIProcess/Launcher/cocoa/ProcessLauncherCocoa.mm:
(WebKit::webContentServiceName):
(WebKit::serviceName):
(WebKit::ProcessLauncher::launchProcess):
* Source/WebKit/UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::setCustomWebContentServiceBundleIdentifier): Deleted.
* Source/WebKit/UIProcess/WebProcessPool.h:
* Source/WebKit/UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::getLaunchOptions):

Canonical link: https://commits.webkit.org/262436@main
  • Loading branch information
achristensen07 committed Mar 31, 2023
1 parent 4031250 commit e25587a
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ Ref<ProcessPoolConfiguration> ProcessPoolConfiguration::copy()
copy->m_isAutomaticProcessWarmingEnabledByClient = this->m_isAutomaticProcessWarmingEnabledByClient;
copy->m_usesWebProcessCache = this->m_usesWebProcessCache;
copy->m_usesBackForwardCache = this->m_usesBackForwardCache;
copy->m_customWebContentServiceBundleIdentifier = this->m_customWebContentServiceBundleIdentifier;
copy->m_usesSingleWebProcess = m_usesSingleWebProcess;
#if PLATFORM(GTK) && !USE(GTK4)
copy->m_useSystemAppearanceForScrollbars = m_useSystemAppearanceForScrollbars;
Expand Down
4 changes: 0 additions & 4 deletions Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,6 @@ class ProcessPoolConfiguration final : public ObjectImpl<Object::Type::ProcessPo
bool processSwapsOnWindowOpenWithOpener() const { return m_processSwapsOnWindowOpenWithOpener; }
void setProcessSwapsOnWindowOpenWithOpener(bool swaps) { m_processSwapsOnWindowOpenWithOpener = swaps; }

const WTF::String& customWebContentServiceBundleIdentifier() const { return m_customWebContentServiceBundleIdentifier; }
void setCustomWebContentServiceBundleIdentifier(const WTF::String& customWebContentServiceBundleIdentifier) { m_customWebContentServiceBundleIdentifier = customWebContentServiceBundleIdentifier; }

#if PLATFORM(GTK) && !USE(GTK4)
bool useSystemAppearanceForScrollbars() const { return m_useSystemAppearanceForScrollbars; }
void setUseSystemAppearanceForScrollbars(bool useSystemAppearanceForScrollbars) { m_useSystemAppearanceForScrollbars = useSystemAppearanceForScrollbars; }
Expand Down Expand Up @@ -186,7 +183,6 @@ class ProcessPoolConfiguration final : public ObjectImpl<Object::Type::ProcessPo
bool m_usesWebProcessCache { false };
bool m_usesBackForwardCache { true };
bool m_clientWouldBenefitFromAutomaticProcessPrewarming { false };
WTF::String m_customWebContentServiceBundleIdentifier;
bool m_shouldConfigureJSCForTesting { false };
bool m_isJITEnabled { true };
bool m_usesSingleWebProcess { false };
Expand Down
3 changes: 1 addition & 2 deletions Source/WebKit/UIProcess/API/C/WKContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,8 @@ bool WKContextGetUsesSingleWebProcess(WKContextRef contextRef)
return WebKit::toImpl(contextRef)->configuration().usesSingleWebProcess();
}

void WKContextSetCustomWebContentServiceBundleIdentifier(WKContextRef contextRef, WKStringRef name)
void WKContextSetCustomWebContentServiceBundleIdentifier(WKContextRef, WKStringRef)
{
WebKit::toImpl(contextRef)->setCustomWebContentServiceBundleIdentifier(WebKit::toImpl(name)->string());
}

void WKContextSetDiskCacheSpeculativeValidationEnabled(WKContextRef, bool)
Expand Down
2 changes: 1 addition & 1 deletion Source/WebKit/UIProcess/API/C/WKContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ WK_EXPORT void WKContextSetPlugInAutoStartOrigins(WKContextRef contextRef, WKArr
WK_EXPORT void WKContextSetPlugInAutoStartOriginsFilteringOutEntriesAddedAfterTime(WKContextRef contextRef, WKDictionaryRef dictionaryRef, double time);
WK_EXPORT void WKContextRefreshPlugIns(WKContextRef context);

WK_EXPORT void WKContextSetCustomWebContentServiceBundleIdentifier(WKContextRef contextRef, WKStringRef name);
WK_EXPORT void WKContextSetCustomWebContentServiceBundleIdentifier(WKContextRef contextRef, WKStringRef name) WK_C_API_DEPRECATED;

WK_EXPORT void WKContextClearMockGamepadsForTesting(WKContextRef contextRef);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ WK_CLASS_AVAILABLE(macos(10.10), ios(8.0))
@property (nonatomic, copy) NSSet<Class> *customClassesForParameterCoder WK_API_DEPRECATED("No longer supported", macos(10.15.4, WK_MAC_TBA), ios(13.4, WK_IOS_TBA));
@property (nonatomic) NSUInteger maximumProcessCount WK_API_DEPRECATED("It is no longer possible to limit the number of processes", macos(10.0, 10.15), ios(1.0, 13.0));
@property (nonatomic) BOOL usesSingleWebProcess WK_API_AVAILABLE(macos(10.15), ios(13.0));
@property (nonatomic, nullable, copy) NSString *customWebContentServiceBundleIdentifier WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
@property (nonatomic, nullable, copy) NSString *customWebContentServiceBundleIdentifier WK_API_DEPRECATED("No longer supported", macos(10.14.4, WK_MAC_TBA), ios(12.2, WK_IOS_TBA));

@property (nonatomic) BOOL ignoreSynchronousMessagingTimeoutsForTesting WK_API_AVAILABLE(macos(10.12), ios(10.0));
@property (nonatomic) BOOL attrStyleEnabled WK_API_AVAILABLE(macos(10.14.4), ios(12.2));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,11 @@ - (id)copyWithZone:(NSZone *)zone

- (NSString *)customWebContentServiceBundleIdentifier
{
return _processPoolConfiguration->customWebContentServiceBundleIdentifier();
return nil;
}

- (void)setCustomWebContentServiceBundleIdentifier:(NSString *)customWebContentServiceBundleIdentifier
{
_processPoolConfiguration->setCustomWebContentServiceBundleIdentifier(customWebContentServiceBundleIdentifier);
}

- (BOOL)configureJSCForTesting
Expand Down
1 change: 0 additions & 1 deletion Source/WebKit/UIProcess/Launcher/ProcessLauncher.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ class ProcessLauncher : public ThreadSafeRefCountedAndCanMakeThreadSafeWeakPtr<P
HashMap<String, String> extraInitializationData;
bool nonValidInjectedCodeAllowed { false };
bool shouldMakeProcessLaunchFailForTesting { false };
CString customWebContentServiceBundleIdentifier;

#if PLATFORM(GTK) || PLATFORM(WPE)
HashMap<CString, SandboxPermission> extraSandboxPaths;
Expand Down
15 changes: 7 additions & 8 deletions Source/WebKit/UIProcess/Launcher/cocoa/ProcessLauncherCocoa.mm
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,22 @@

namespace WebKit {

static const char* webContentServiceName(bool nonValidInjectedCodeAllowed, ProcessLauncher::Client* client)
static const char* webContentServiceName(const ProcessLauncher::LaunchOptions& launchOptions, ProcessLauncher::Client* client)
{
if (launchOptions.extraInitializationData.get<HashTranslatorASCIILiteral>("is-webcontent-crashy"_s) == "1"_s)
return "com.apple.WebKit.WebContent.Crashy";

if (client && client->shouldEnableLockdownMode())
return "com.apple.WebKit.WebContent.CaptivePortal";

return nonValidInjectedCodeAllowed ? "com.apple.WebKit.WebContent.Development" : "com.apple.WebKit.WebContent";
return launchOptions.nonValidInjectedCodeAllowed ? "com.apple.WebKit.WebContent.Development" : "com.apple.WebKit.WebContent";
}

static const char* serviceName(const ProcessLauncher::LaunchOptions& launchOptions, ProcessLauncher::Client* client)
{
switch (launchOptions.processType) {
case ProcessLauncher::ProcessType::Web:
return webContentServiceName(launchOptions.nonValidInjectedCodeAllowed, client);
return webContentServiceName(launchOptions, client);
case ProcessLauncher::ProcessType::Network:
return "com.apple.WebKit.Networking";
#if ENABLE(GPU_PROCESS)
Expand All @@ -88,11 +91,7 @@
{
ASSERT(!m_xpcConnection);

const char* name;
if (!m_launchOptions.customWebContentServiceBundleIdentifier.isNull())
name = m_launchOptions.customWebContentServiceBundleIdentifier.data();
else
name = serviceName(m_launchOptions, m_client);
const char* name = serviceName(m_launchOptions, m_client);

m_xpcConnection = adoptOSObject(xpc_connection_create(name, nullptr));

Expand Down
9 changes: 0 additions & 9 deletions Source/WebKit/UIProcess/WebProcessPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,15 +366,6 @@ void WebProcessPool::setAutomationClient(std::unique_ptr<API::AutomationClient>&
m_automationClient = WTFMove(automationClient);
}

void WebProcessPool::setCustomWebContentServiceBundleIdentifier(const String& customWebContentServiceBundleIdentifier)
{
// Guard against API misuse.
if (!customWebContentServiceBundleIdentifier.isAllASCII())
CRASH();

m_configuration->setCustomWebContentServiceBundleIdentifier(customWebContentServiceBundleIdentifier);
}

void WebProcessPool::setOverrideLanguages(Vector<String>&& languages)
{
WebKit::setOverrideLanguages(WTFMove(languages));
Expand Down
3 changes: 0 additions & 3 deletions Source/WebKit/UIProcess/WebProcessPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,6 @@ class WebProcessPool final
void setLegacyDownloadClient(RefPtr<API::DownloadClient>&&);
void setAutomationClient(std::unique_ptr<API::AutomationClient>&&);

void setCustomWebContentServiceBundleIdentifier(const String&);
const String& customWebContentServiceBundleIdentifier() { return m_configuration->customWebContentServiceBundleIdentifier(); }

const Vector<Ref<WebProcessProxy>>& processes() const { return m_processes; }

// WebProcessProxy object which does not have a running process which is used for convenience, to avoid
Expand Down
6 changes: 1 addition & 5 deletions Source/WebKit/UIProcess/WebProcessProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,6 @@ void WebProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& launchOpt

AuxiliaryProcessProxy::getLaunchOptions(launchOptions);

if (!m_processPool->customWebContentServiceBundleIdentifier().isEmpty())
launchOptions.customWebContentServiceBundleIdentifier = m_processPool->customWebContentServiceBundleIdentifier().ascii();
if (WebKit::isInspectorProcessPool(processPool()))
launchOptions.extraInitializationData.add<HashTranslatorASCIILiteral>("inspector-process"_s, "1"_s);

Expand All @@ -509,10 +507,8 @@ void WebProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& launchOpt
}

#if ENABLE(WEBCONTENT_CRASH_TESTING)
if (isCrashyProcess()) {
launchOptions.customWebContentServiceBundleIdentifier = toCString("com.apple.WebKit.WebContent.Crashy");
if (isCrashyProcess())
launchOptions.extraInitializationData.add<HashTranslatorASCIILiteral>("is-webcontent-crashy"_s, "1"_s);
}
#endif

if (m_serviceWorkerInformation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
auto configuration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);

[configuration setInjectedBundleURL:[NSURL fileURLWithPath:@"/path/to/injected.wkbundle"]];
[configuration setCustomWebContentServiceBundleIdentifier:@"org.webkit.WebContent.custom"];
[configuration setIgnoreSynchronousMessagingTimeoutsForTesting:YES];
[configuration setAttrStyleEnabled:YES];
[configuration setAdditionalReadAccessAllowedURLs:@[ [NSURL fileURLWithPath:@"/path/to/allow/read/access/"] ]];
Expand All @@ -57,7 +56,6 @@
auto copy = adoptNS([configuration copy]);

EXPECT_TRUE([[configuration injectedBundleURL] isEqual:[copy injectedBundleURL]]);
EXPECT_TRUE([[configuration customWebContentServiceBundleIdentifier] isEqual:[copy customWebContentServiceBundleIdentifier]]);
EXPECT_EQ([configuration ignoreSynchronousMessagingTimeoutsForTesting], [copy ignoreSynchronousMessagingTimeoutsForTesting]);
EXPECT_EQ([configuration attrStyleEnabled], [copy attrStyleEnabled]);
EXPECT_TRUE([[configuration additionalReadAccessAllowedURLs] isEqual:[copy additionalReadAccessAllowedURLs]]);
Expand Down

0 comments on commit e25587a

Please sign in to comment.