Title: [275013] trunk/Source
Revision
275013
Author
[email protected]
Date
2021-03-25 03:14:43 -0700 (Thu, 25 Mar 2021)

Log Message

All Books quirks are flakily not applied in modern WebKit
https://bugs.webkit.org/show_bug.cgi?id=157101
<rdar://problem/25965028>

Reviewed by Darin Adler.

Source/WebCore:

No new tests; I haven't found a way to write a test that doesn't involve
adding a new parameter to the process bootstrap message, which seems
out of the realm of reason for a test.

* bindings/js/CommonVM.cpp:
(WebCore::commonVMSlow):
(WebCore::globalConstRedeclarationShouldThrow): Deleted.
Stop hardcoding globalConstRedeclarationShouldThrow based on the UI process identity.

* platform/RuntimeApplicationChecks.cpp:
(WebCore::isInAuxiliaryProcess):
* platform/RuntimeApplicationChecks.h:
* platform/cocoa/RuntimeApplicationChecksCocoa.mm:
(WebCore::applicationBundleIdentifier):
(WebCore::setApplicationBundleIdentifierOverride):
Add an assertion to catch any future case where a bundle check is queried
in a auxiliary process before the hosting application bundle identifier is set.

Source/WebKit:

In r200121, a quirk was introduced that queried the isIBooks()
RuntimeApplicationChecks method from inside commonVM().

RuntimeApplicationChecks bundle checks cache the result of the bundle
check, and, as such, must not be called until the bundle identifer of
the UI application is known. In legacy WebKit, this is not a problem,
because the check is running in the application process; in modern WebKit,
there is a short window between process launch and the InitializeWebProcess
message being received where we won't know the bundle identifier, and if
isIBooks() (or any other bundle check) is called during this time, it will
cache the wrong result.

It is possible for commonVM() to be called in this window; one possible path
to this is by triggering an os_log_fault during this time, which WebKit
observes (via os_state_add_handler()) in order to dump memory usage
(which happens to call commonVM() and results in isIBooks getting called
and caching the wrong value).

Add an assertion, and move the quirk to live as a setting on the process
pool configuration, to be set via SPI by Books, instead of as a bundle check.

Also, ensure that client bundle identifier and SDK version are set in
all WebKit subprocesses, so that bundle/SDK checks work everywhere
(previously, the GPU process was using SDK checks without having pushed
the values from the UI process, resulting in incorrect results, and
running afoul of the assertion added above).

* UIProcess/API/APIProcessPoolConfiguration.cpp:
(API::ProcessPoolConfiguration::copy):
(API::defaultShouldThrowExceptionForGlobalConstantRedeclaration):
* UIProcess/API/APIProcessPoolConfiguration.h:
* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
* UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
(-[_WKProcessPoolConfiguration shouldThrowExceptionForGlobalConstantRedeclaration]):
(-[_WKProcessPoolConfiguration setShouldThrowExceptionForGlobalConstantRedeclaration:]):
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::initializeNewWebProcess):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):
Plumb a new _WKProcessPoolConfiguration parameter to the Web Content process,
and set the bit on the commonVM when launched.

* NetworkProcess/NetworkProcessCreationParameters.cpp:
(WebKit::NetworkProcessCreationParameters::encode const):
(WebKit::NetworkProcessCreationParameters::decode):
* NetworkProcess/NetworkProcessCreationParameters.h:
* NetworkProcess/cocoa/NetworkProcessCocoa.mm:
(WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
* Shared/AuxiliaryProcess.cpp:
(WebKit::AuxiliaryProcess::initialize):
(WebKit::AuxiliaryProcess::platformInitialize):
* Shared/AuxiliaryProcess.h:
* Shared/Cocoa/AuxiliaryProcessCocoa.mm:
(WebKit::initializeTimerCoalescingPolicy):
(WebKit::AuxiliaryProcess::platformInitialize):
* Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h:
(WebKit::XPCServiceInitializer):
* Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.mm:
(WebKit::XPCServiceInitializerDelegate::getClientSDKVersion):
* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode const):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:
Remove an extra unused member.
* Shared/ios/AuxiliaryProcessIOS.mm:
(WebKit::AuxiliaryProcess::platformInitialize): Deleted.
* Shared/mac/AuxiliaryProcessMac.mm:
(WebKit::initializeTimerCoalescingPolicy): Deleted.
(WebKit::AuxiliaryProcess::platformInitialize): Deleted.
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeWebProcess):
(WebKit::WebProcessPool::platformInitializeNetworkProcess):
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):
Plumb the client bundle identifer and SDK version to all auxiliary processes
at process initialization time instead of InitializeWebProcess/NetworkProcess
message receipt time, closing the window in which it is invalid to use
bundle checks, and ensuring that bundle checks work in all processes.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (275012 => 275013)


--- trunk/Source/WebCore/ChangeLog	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebCore/ChangeLog	2021-03-25 10:14:43 UTC (rev 275013)
@@ -1,3 +1,29 @@
+2021-03-25  Tim Horton  <[email protected]>
+
+        All Books quirks are flakily not applied in modern WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=157101
+        <rdar://problem/25965028>
+
+        Reviewed by Darin Adler.
+
+        No new tests; I haven't found a way to write a test that doesn't involve
+        adding a new parameter to the process bootstrap message, which seems
+        out of the realm of reason for a test.
+
+        * bindings/js/CommonVM.cpp:
+        (WebCore::commonVMSlow):
+        (WebCore::globalConstRedeclarationShouldThrow): Deleted.
+        Stop hardcoding globalConstRedeclarationShouldThrow based on the UI process identity.
+
+        * platform/RuntimeApplicationChecks.cpp:
+        (WebCore::isInAuxiliaryProcess):
+        * platform/RuntimeApplicationChecks.h:
+        * platform/cocoa/RuntimeApplicationChecksCocoa.mm:
+        (WebCore::applicationBundleIdentifier):
+        (WebCore::setApplicationBundleIdentifierOverride):
+        Add an assertion to catch any future case where a bundle check is queried
+        in a auxiliary process before the hosting application bundle identifier is set.
+
 2021-03-24  Yusuke Suzuki  <[email protected]>
 
         All string resources from UserAgentStyleSheets / UserAgentScripts should be used as non-copying StringImpl

Modified: trunk/Source/WebCore/bindings/js/CommonVM.cpp (275012 => 275013)


--- trunk/Source/WebCore/bindings/js/CommonVM.cpp	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebCore/bindings/js/CommonVM.cpp	2021-03-25 10:14:43 UTC (rev 275013)
@@ -28,7 +28,6 @@
 
 #include "DOMWindow.h"
 #include "Frame.h"
-#include "RuntimeApplicationChecks.h"
 #include "ScriptController.h"
 #include "WebCoreJSClientData.h"
 #include <_javascript_Core/HeapInlines.h>
@@ -44,16 +43,6 @@
 
 namespace WebCore {
 
-// FIXME: <rdar://problem/25965028> This should be removed or replaced with a Setting that iBooks can use if it is still needed.
-static bool globalConstRedeclarationShouldThrow()
-{
-#if PLATFORM(COCOA)
-    return !CocoaApplication::isIBooks();
-#else
-    return true;
-#endif
-}
-
 JSC::VM* g_commonVMOrNull;
 
 JSC::VM& commonVMSlow()
@@ -84,8 +73,6 @@
     vm.heap.machineThreads().addCurrentThread();
 #endif
 
-    vm.setGlobalConstRedeclarationShouldThrow(globalConstRedeclarationShouldThrow());
-
     JSVMClientData::initNormalWorld(&vm, WorkerThreadType::Main);
 
     return vm;

Modified: trunk/Source/WebCore/platform/RuntimeApplicationChecks.cpp (275012 => 275013)


--- trunk/Source/WebCore/platform/RuntimeApplicationChecks.cpp	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebCore/platform/RuntimeApplicationChecks.cpp	2021-03-25 10:14:43 UTC (rev 275013)
@@ -66,6 +66,11 @@
     return auxiliaryProcessType;
 }
 
+bool isInAuxiliaryProcess()
+{
+    return !!auxiliaryProcessType();
+}
+
 void setAuxiliaryProcessType(AuxiliaryProcessType type)
 {
     auxiliaryProcessType() = type;

Modified: trunk/Source/WebCore/platform/RuntimeApplicationChecks.h (275012 => 275013)


--- trunk/Source/WebCore/platform/RuntimeApplicationChecks.h	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebCore/platform/RuntimeApplicationChecks.h	2021-03-25 10:14:43 UTC (rev 275013)
@@ -47,6 +47,7 @@
 WEBCORE_EXPORT void setAuxiliaryProcessType(AuxiliaryProcessType);
 WEBCORE_EXPORT bool checkAuxiliaryProcessType(AuxiliaryProcessType);
 
+bool isInAuxiliaryProcess();
 inline bool isInWebProcess() { return checkAuxiliaryProcessType(AuxiliaryProcessType::WebContent); }
 inline bool isInNetworkProcess() { return checkAuxiliaryProcessType(AuxiliaryProcessType::Network); }
 #if ENABLE(GPU_PROCESS)

Modified: trunk/Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm (275012 => 275013)


--- trunk/Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebCore/platform/cocoa/RuntimeApplicationChecksCocoa.mm	2021-03-25 10:14:43 UTC (rev 275013)
@@ -65,6 +65,7 @@
     ASSERT(identifier.isNull() || RunLoop::isMain());
     if (identifier.isNull())
         identifier = bundleIdentifier();
+    ASSERT_WITH_MESSAGE(!isInAuxiliaryProcess() || !!identifier, "applicationBundleIsEqualTo() and applicationBundleStartsWith() must not be called before setApplicationBundleIdentifier() in auxiliary processes");
     return identifier.isNull() ? String([[NSBundle mainBundle] bundleIdentifier]) : identifier;
 }
 
@@ -77,7 +78,7 @@
 void setApplicationBundleIdentifierOverride(const String& identifier)
 {
     ASSERT(RunLoop::isMain());
-    ASSERT_WITH_MESSAGE(!applicationBundleIdentifierOverrideWasQueried, "applicationBundleIsEqualTo() and applicationBundleStartsWith() should not be called before setApplicationBundleIdentifier()");
+    ASSERT_WITH_MESSAGE(!applicationBundleIdentifierOverrideWasQueried, "applicationBundleIsEqualTo() and applicationBundleStartsWith() must not be called before setApplicationBundleIdentifierOverride()");
     bundleIdentifierOverride() = identifier;
 }
 

Modified: trunk/Source/WebKit/ChangeLog (275012 => 275013)


--- trunk/Source/WebKit/ChangeLog	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/ChangeLog	2021-03-25 10:14:43 UTC (rev 275013)
@@ -1,3 +1,92 @@
+2021-03-25  Tim Horton  <[email protected]>
+
+        All Books quirks are flakily not applied in modern WebKit
+        https://bugs.webkit.org/show_bug.cgi?id=157101
+        <rdar://problem/25965028>
+
+        Reviewed by Darin Adler.
+
+        In r200121, a quirk was introduced that queried the isIBooks()
+        RuntimeApplicationChecks method from inside commonVM().
+
+        RuntimeApplicationChecks bundle checks cache the result of the bundle
+        check, and, as such, must not be called until the bundle identifer of
+        the UI application is known. In legacy WebKit, this is not a problem,
+        because the check is running in the application process; in modern WebKit,
+        there is a short window between process launch and the InitializeWebProcess
+        message being received where we won't know the bundle identifier, and if
+        isIBooks() (or any other bundle check) is called during this time, it will
+        cache the wrong result.
+
+        It is possible for commonVM() to be called in this window; one possible path
+        to this is by triggering an os_log_fault during this time, which WebKit
+        observes (via os_state_add_handler()) in order to dump memory usage
+        (which happens to call commonVM() and results in isIBooks getting called
+        and caching the wrong value).
+
+        Add an assertion, and move the quirk to live as a setting on the process
+        pool configuration, to be set via SPI by Books, instead of as a bundle check.
+
+        Also, ensure that client bundle identifier and SDK version are set in 
+        all WebKit subprocesses, so that bundle/SDK checks work everywhere
+        (previously, the GPU process was using SDK checks without having pushed
+        the values from the UI process, resulting in incorrect results, and
+        running afoul of the assertion added above).
+
+        * UIProcess/API/APIProcessPoolConfiguration.cpp:
+        (API::ProcessPoolConfiguration::copy):
+        (API::defaultShouldThrowExceptionForGlobalConstantRedeclaration):
+        * UIProcess/API/APIProcessPoolConfiguration.h:
+        * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
+        * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
+        (-[_WKProcessPoolConfiguration shouldThrowExceptionForGlobalConstantRedeclaration]):
+        (-[_WKProcessPoolConfiguration setShouldThrowExceptionForGlobalConstantRedeclaration:]):
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::initializeNewWebProcess):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::initializeWebProcess):
+        Plumb a new _WKProcessPoolConfiguration parameter to the Web Content process,
+        and set the bit on the commonVM when launched.
+
+        * NetworkProcess/NetworkProcessCreationParameters.cpp:
+        (WebKit::NetworkProcessCreationParameters::encode const):
+        (WebKit::NetworkProcessCreationParameters::decode):
+        * NetworkProcess/NetworkProcessCreationParameters.h:
+        * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
+        (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
+        * Shared/AuxiliaryProcess.cpp:
+        (WebKit::AuxiliaryProcess::initialize):
+        (WebKit::AuxiliaryProcess::platformInitialize):
+        * Shared/AuxiliaryProcess.h:
+        * Shared/Cocoa/AuxiliaryProcessCocoa.mm:
+        (WebKit::initializeTimerCoalescingPolicy):
+        (WebKit::AuxiliaryProcess::platformInitialize):
+        * Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h:
+        (WebKit::XPCServiceInitializer):
+        * Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.mm:
+        (WebKit::XPCServiceInitializerDelegate::getClientSDKVersion):
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode const):
+        (WebKit::WebProcessCreationParameters::decode):
+        * Shared/WebProcessCreationParameters.h:
+        Remove an extra unused member.
+        * Shared/ios/AuxiliaryProcessIOS.mm:
+        (WebKit::AuxiliaryProcess::platformInitialize): Deleted.
+        * Shared/mac/AuxiliaryProcessMac.mm:
+        (WebKit::initializeTimerCoalescingPolicy): Deleted.
+        (WebKit::AuxiliaryProcess::platformInitialize): Deleted.
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::platformInitializeWebProcess):
+        (WebKit::WebProcessPool::platformInitializeNetworkProcess):
+        * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
+        (WebKit::ProcessLauncher::launchProcess):
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess):
+        Plumb the client bundle identifer and SDK version to all auxiliary processes
+        at process initialization time instead of InitializeWebProcess/NetworkProcess
+        message receipt time, closing the window in which it is invalid to use
+        bundle checks, and ensuring that bundle checks work in all processes.
+
 2021-03-24  Julian Gonzalez  <[email protected]>
 
         Crash in TextChecker::updateSpellingUIWithGrammarString()

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp (275012 => 275013)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp	2021-03-25 10:14:43 UTC (rev 275013)
@@ -53,7 +53,6 @@
     encoder << urlSchemesRegisteredForCustomProtocols;
 #if PLATFORM(COCOA)
     encoder << uiProcessBundleIdentifier;
-    encoder << uiProcessSDKVersion;
     IPC::encode(encoder, networkATSContext.get());
 #endif
 #if USE(SOUP)
@@ -111,8 +110,6 @@
 #if PLATFORM(COCOA)
     if (!decoder.decode(result.uiProcessBundleIdentifier))
         return false;
-    if (!decoder.decode(result.uiProcessSDKVersion))
-        return false;
     if (!IPC::decode(decoder, result.networkATSContext))
         return false;
 #endif

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h (275012 => 275013)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h	2021-03-25 10:14:43 UTC (rev 275013)
@@ -66,7 +66,6 @@
 
 #if PLATFORM(COCOA)
     String uiProcessBundleIdentifier;
-    uint32_t uiProcessSDKVersion { 0 };
     RetainPtr<CFDataRef> networkATSContext;
 #endif
 

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm (275012 => 275013)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm	2021-03-25 10:14:43 UTC (rev 275013)
@@ -73,9 +73,6 @@
 
 void NetworkProcess::platformInitializeNetworkProcessCocoa(const NetworkProcessCreationParameters& parameters)
 {
-    WebCore::setApplicationBundleIdentifier(parameters.uiProcessBundleIdentifier);
-    setApplicationSDKVersion(parameters.uiProcessSDKVersion);
-
 #if PLATFORM(IOS_FAMILY)
     SandboxExtension::consumePermanently(parameters.cookieStorageDirectoryExtensionHandle);
     SandboxExtension::consumePermanently(parameters.containerCachesDirectoryExtensionHandle);

Modified: trunk/Source/WebKit/Shared/AuxiliaryProcess.cpp (275012 => 275013)


--- trunk/Source/WebKit/Shared/AuxiliaryProcess.cpp	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/Shared/AuxiliaryProcess.cpp	2021-03-25 10:14:43 UTC (rev 275013)
@@ -69,7 +69,7 @@
     RELEASE_ASSERT_WITH_MESSAGE(parameters.processIdentifier, "Unable to initialize child process without a WebCore process identifier");
     Process::setIdentifier(*parameters.processIdentifier);
 
-    platformInitialize();
+    platformInitialize(parameters);
 
 #if PLATFORM(COCOA)
     m_priorityBoostMessage = parameters.priorityBoostMessage;
@@ -237,7 +237,7 @@
 }
 
 #if !PLATFORM(COCOA)
-void AuxiliaryProcess::platformInitialize()
+void AuxiliaryProcess::platformInitialize(const AuxiliaryProcessInitializationParameters&)
 {
 }
 

Modified: trunk/Source/WebKit/Shared/AuxiliaryProcess.h (275012 => 275013)


--- trunk/Source/WebKit/Shared/AuxiliaryProcess.h	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/Shared/AuxiliaryProcess.h	2021-03-25 10:14:43 UTC (rev 275013)
@@ -137,7 +137,7 @@
 
     void terminationTimerFired();
 
-    void platformInitialize();
+    void platformInitialize(const AuxiliaryProcessInitializationParameters&);
     void platformStopRunLoop();
 
     // The timeout, in seconds, before this process will be terminated if termination
@@ -163,6 +163,8 @@
 struct AuxiliaryProcessInitializationParameters {
     String uiProcessName;
     String clientIdentifier;
+    String clientBundleIdentifier;
+    uint32_t clientSDKVersion;
     Optional<WebCore::ProcessIdentifier> processIdentifier;
     IPC::Connection::Identifier connectionIdentifier;
     HashMap<String, String> extraInitializationData;

Modified: trunk/Source/WebKit/Shared/Cocoa/AuxiliaryProcessCocoa.mm (275012 => 275013)


--- trunk/Source/WebKit/Shared/Cocoa/AuxiliaryProcessCocoa.mm	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/Shared/Cocoa/AuxiliaryProcessCocoa.mm	2021-03-25 10:14:43 UTC (rev 275013)
@@ -28,10 +28,42 @@
 
 #import "WKCrashReporter.h"
 #import "XPCServiceEntryPoint.h"
+#import <WebCore/FloatingPointEnvironment.h>
+#import <WebCore/RuntimeApplicationChecks.h>
+#import <mach/task.h>
 #import <wtf/cocoa/Entitlements.h>
+#import <wtf/cocoa/RuntimeApplicationChecksCocoa.h>
 
 namespace WebKit {
 
+#if PLATFORM(MAC) || PLATFORM(MACCATALYST)
+static void initializeTimerCoalescingPolicy()
+{
+    // Set task_latency and task_throughput QOS tiers as appropriate for a visible application.
+    struct task_qos_policy qosinfo = { LATENCY_QOS_TIER_0, THROUGHPUT_QOS_TIER_0 };
+    kern_return_t kr = task_policy_set(mach_task_self(), TASK_BASE_QOS_POLICY, (task_policy_t)&qosinfo, TASK_QOS_POLICY_COUNT);
+    ASSERT_UNUSED(kr, kr == KERN_SUCCESS);
+}
+#endif
+
+void AuxiliaryProcess::platformInitialize(const AuxiliaryProcessInitializationParameters& parameters)
+{
+#if PLATFORM(MAC) || PLATFORM(MACCATALYST)
+    initializeTimerCoalescingPolicy();
+#endif
+
+    FloatingPointEnvironment& floatingPointEnvironment = FloatingPointEnvironment::singleton();
+#if PLATFORM(IOS_FAMILY) && !PLATFORM(MACCATALYST)
+    floatingPointEnvironment.enableDenormalSupport();
+#endif
+    floatingPointEnvironment.saveMainThreadEnvironment();
+
+    [[NSFileManager defaultManager] changeCurrentDirectoryPath:[[NSBundle mainBundle] bundlePath]];
+
+    WebCore::setApplicationBundleIdentifier(parameters.clientBundleIdentifier);
+    setApplicationSDKVersion(parameters.clientSDKVersion);
+}
+
 void AuxiliaryProcess::didReceiveInvalidMessage(IPC::Connection&, IPC::MessageName messageName)
 {
     auto errorMessage = makeString("Received invalid message: '", description(messageName), "' (", messageName, ')');

Modified: trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h (275012 => 275013)


--- trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h	2021-03-25 10:14:43 UTC (rev 275013)
@@ -61,6 +61,8 @@
     virtual bool getConnectionIdentifier(IPC::Connection::Identifier& identifier);
     virtual bool getProcessIdentifier(WebCore::ProcessIdentifier&);
     virtual bool getClientIdentifier(String& clientIdentifier);
+    virtual bool getClientBundleIdentifier(String& clientBundleIdentifier);
+    virtual bool getClientSDKVersion(uint32_t& clientSDKVersion);
     virtual bool getClientProcessName(String& clientProcessName);
     virtual bool getExtraInitializationData(HashMap<String, String>& extraInitializationData);
 
@@ -114,6 +116,12 @@
     if (!delegate.getClientIdentifier(parameters.clientIdentifier))
         exit(EXIT_FAILURE);
 
+    if (!delegate.getClientBundleIdentifier(parameters.clientBundleIdentifier))
+        exit(EXIT_FAILURE);
+
+    if (!delegate.getClientSDKVersion(parameters.clientSDKVersion))
+        exit(EXIT_FAILURE);
+
     WebCore::ProcessIdentifier processIdentifier;
     if (!delegate.getProcessIdentifier(processIdentifier))
         exit(EXIT_FAILURE);

Modified: trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.mm (275012 => 275013)


--- trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.mm	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.mm	2021-03-25 10:14:43 UTC (rev 275013)
@@ -72,11 +72,23 @@
 bool XPCServiceInitializerDelegate::getClientIdentifier(String& clientIdentifier)
 {
     clientIdentifier = xpc_dictionary_get_string(m_initializerMessage, "client-identifier");
-    if (clientIdentifier.isEmpty())
-        return false;
-    return true;
+    return !clientIdentifier.isEmpty();
 }
 
+bool XPCServiceInitializerDelegate::getClientBundleIdentifier(String& clientBundleIdentifier)
+{
+    clientBundleIdentifier = xpc_dictionary_get_string(m_initializerMessage, "client-bundle-identifier");
+    return !clientBundleIdentifier.isEmpty();
+}
+
+bool XPCServiceInitializerDelegate::getClientSDKVersion(uint32_t& clientSDKVersion)
+{
+    auto string = xpc_dictionary_get_string(m_initializerMessage, "client-sdk-version");
+    bool ok;
+    clientSDKVersion = charactersToUIntStrict(reinterpret_cast<const LChar*>(string), string ? std::strlen(string) : 0, &ok);
+    return ok;
+}
+
 bool XPCServiceInitializerDelegate::getProcessIdentifier(ProcessIdentifier& identifier)
 {
     String processIdentifierString = xpc_dictionary_get_string(m_initializerMessage, "process-identifier");

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp (275012 => 275013)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.cpp	2021-03-25 10:14:43 UTC (rev 275013)
@@ -96,7 +96,6 @@
     encoder << backForwardCacheCapacity;
 #if PLATFORM(COCOA)
     encoder << uiProcessBundleIdentifier;
-    encoder << uiProcessSDKVersion;
     encoder << latencyQOS;
     encoder << throughputQOS;
 #endif
@@ -119,6 +118,7 @@
 
     encoder << memoryCacheDisabled;
     encoder << attrStyleEnabled;
+    encoder << shouldThrowExceptionForGlobalConstantRedeclaration;
 
 #if ENABLE(SERVICE_CONTROLS)
     encoder << hasImageServices;
@@ -321,8 +321,6 @@
 #if PLATFORM(COCOA)
     if (!decoder.decode(parameters.uiProcessBundleIdentifier))
         return false;
-    if (!decoder.decode(parameters.uiProcessSDKVersion))
-        return false;
     if (!decoder.decode(parameters.latencyQOS))
         return false;
     if (!decoder.decode(parameters.throughputQOS))
@@ -371,6 +369,8 @@
         return false;
     if (!decoder.decode(parameters.attrStyleEnabled))
         return false;
+    if (!decoder.decode(parameters.shouldThrowExceptionForGlobalConstantRedeclaration))
+        return false;
 
 #if ENABLE(SERVICE_CONTROLS)
     if (!decoder.decode(parameters.hasImageServices))

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.h (275012 => 275013)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2021-03-25 10:14:43 UTC (rev 275013)
@@ -126,7 +126,7 @@
     bool hasStylusDevice { false };
     bool memoryCacheDisabled { false };
     bool attrStyleEnabled { false };
-    bool useGPUProcessForMediaEnabled { false };
+    bool shouldThrowExceptionForGlobalConstantRedeclaration { true };
 
 #if ENABLE(SERVICE_CONTROLS)
     bool hasImageServices { false };
@@ -140,7 +140,6 @@
 
 #if PLATFORM(COCOA)
     String uiProcessBundleIdentifier;
-    uint32_t uiProcessSDKVersion { 0 };
     int latencyQOS { 0 };
     int throughputQOS { 0 };
 #endif

Modified: trunk/Source/WebKit/Shared/ios/AuxiliaryProcessIOS.mm (275012 => 275013)


--- trunk/Source/WebKit/Shared/ios/AuxiliaryProcessIOS.mm	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/Shared/ios/AuxiliaryProcessIOS.mm	2021-03-25 10:14:43 UTC (rev 275013)
@@ -41,14 +41,6 @@
 
 namespace WebKit {
 
-void AuxiliaryProcess::platformInitialize()
-{
-    FloatingPointEnvironment& floatingPointEnvironment = FloatingPointEnvironment::singleton(); 
-    floatingPointEnvironment.enableDenormalSupport(); 
-    floatingPointEnvironment.saveMainThreadEnvironment(); 
-    [[NSFileManager defaultManager] changeCurrentDirectoryPath:[[NSBundle mainBundle] bundlePath]];
-}
-
 void AuxiliaryProcess::initializeSandbox(const AuxiliaryProcessInitializationParameters&, SandboxInitializationParameters&)
 {
     RELEASE_ASSERT_NOT_REACHED();

Modified: trunk/Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm (275012 => 275013)


--- trunk/Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm	2021-03-25 10:14:43 UTC (rev 275013)
@@ -36,7 +36,6 @@
 #import "WKFoundation.h"
 #import "XPCServiceEntryPoint.h"
 #import <WebCore/FileHandle.h>
-#import <WebCore/FloatingPointEnvironment.h>
 #import <WebCore/SystemVersion.h>
 #import <mach-o/dyld.h>
 #import <mach/mach.h>
@@ -145,14 +144,6 @@
 constexpr uint32_t CachedSandboxVersionNumber = 1;
 #endif // USE(CACHE_COMPILED_SANDBOX)
 
-static void initializeTimerCoalescingPolicy()
-{
-    // Set task_latency and task_throughput QOS tiers as appropriate for a visible application.
-    struct task_qos_policy qosinfo = { LATENCY_QOS_TIER_0, THROUGHPUT_QOS_TIER_0 };
-    kern_return_t kr = task_policy_set(mach_task_self(), TASK_BASE_QOS_POLICY, (task_policy_t)&qosinfo, TASK_QOS_POLICY_COUNT);
-    ASSERT_UNUSED(kr, kr == KERN_SUCCESS);
-}
-
 void AuxiliaryProcess::launchServicesCheckIn()
 {
 #if HAVE(CSCHECKFIXDISABLE)
@@ -164,15 +155,6 @@
     RetainPtr<CFDictionaryRef> unused = _LSApplicationCheckIn(kLSDefaultSessionID, CFBundleGetInfoDictionary(CFBundleGetMainBundle()));
 }
 
-void AuxiliaryProcess::platformInitialize()
-{
-    initializeTimerCoalescingPolicy();
-
-    FloatingPointEnvironment::singleton().saveMainThreadEnvironment();
-
-    [[NSFileManager defaultManager] changeCurrentDirectoryPath:[[NSBundle mainBundle] bundlePath]];
-}
-
 static OSStatus enableSandboxStyleFileQuarantine()
 {
 #if !PLATFORM(MACCATALYST)

Modified: trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp (275012 => 275013)


--- trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp	2021-03-25 10:14:43 UTC (rev 275013)
@@ -52,6 +52,7 @@
     copy->m_fullySynchronousModeIsAllowedForTesting = this->m_fullySynchronousModeIsAllowedForTesting;
     copy->m_ignoreSynchronousMessagingTimeoutsForTesting = this->m_ignoreSynchronousMessagingTimeoutsForTesting;
     copy->m_attrStyleEnabled = this->m_attrStyleEnabled;
+    copy->m_shouldThrowExceptionForGlobalConstantRedeclaration = this->m_shouldThrowExceptionForGlobalConstantRedeclaration;
     copy->m_overrideLanguages = this->m_overrideLanguages;
     copy->m_alwaysRunsAtBackgroundPriority = this->m_alwaysRunsAtBackgroundPriority;
     copy->m_shouldTakeUIBackgroundAssertion = this->m_shouldTakeUIBackgroundAssertion;

Modified: trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h (275012 => 275013)


--- trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h	2021-03-25 10:14:43 UTC (rev 275013)
@@ -94,6 +94,9 @@
 
     bool attrStyleEnabled() const { return m_attrStyleEnabled; }
     void setAttrStyleEnabled(bool enabled) { m_attrStyleEnabled = enabled; }
+    
+    bool shouldThrowExceptionForGlobalConstantRedeclaration() const { return m_shouldThrowExceptionForGlobalConstantRedeclaration; }
+    void setShouldThrowExceptionForGlobalConstantRedeclaration(bool shouldThrow) { m_shouldThrowExceptionForGlobalConstantRedeclaration = shouldThrow; }
 
     const Vector<WTF::String>& overrideLanguages() const { return m_overrideLanguages; }
     void setOverrideLanguages(Vector<WTF::String>&& languages) { m_overrideLanguages = WTFMove(languages); }
@@ -156,6 +159,7 @@
     bool m_fullySynchronousModeIsAllowedForTesting { false };
     bool m_ignoreSynchronousMessagingTimeoutsForTesting { false };
     bool m_attrStyleEnabled { false };
+    bool m_shouldThrowExceptionForGlobalConstantRedeclaration { true };
     Vector<WTF::String> m_overrideLanguages;
     bool m_alwaysRunsAtBackgroundPriority { false };
     bool m_shouldTakeUIBackgroundAssertion { true };

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h (275012 => 275013)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h	2021-03-25 10:14:43 UTC (rev 275013)
@@ -40,6 +40,9 @@
 @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));
 
+// Defaults to YES.
+@property (nonatomic) BOOL shouldThrowExceptionForGlobalConstantRedeclaration WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+
 @property (nonatomic, copy) NSArray<NSURL *> *additionalReadAccessAllowedURLs WK_API_AVAILABLE(macos(10.13), ios(11.0));
 
 #if TARGET_OS_IPHONE && !TARGET_OS_SIMULATOR

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm (275012 => 275013)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm	2021-03-25 10:14:43 UTC (rev 275013)
@@ -141,6 +141,16 @@
     return _processPoolConfiguration->setAttrStyleEnabled(enabled);
 }
 
+- (BOOL)shouldThrowExceptionForGlobalConstantRedeclaration
+{
+    return _processPoolConfiguration->shouldThrowExceptionForGlobalConstantRedeclaration();
+}
+
+- (void)setShouldThrowExceptionForGlobalConstantRedeclaration:(BOOL)shouldThrow
+{
+    return _processPoolConfiguration->setShouldThrowExceptionForGlobalConstantRedeclaration(shouldThrow);
+}
+
 - (NSArray<NSURL *> *)additionalReadAccessAllowedURLs
 {
     auto paths = _processPoolConfiguration->additionalReadAccessAllowedPaths();

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm (275012 => 275013)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm	2021-03-25 10:14:43 UTC (rev 275013)
@@ -320,7 +320,6 @@
     SandboxExtension::createHandleWithoutResolvingPath(parameters.uiProcessBundleResourcePath, SandboxExtension::Type::ReadOnly, parameters.uiProcessBundleResourcePathExtensionHandle);
 
     parameters.uiProcessBundleIdentifier = applicationBundleIdentifier();
-    parameters.uiProcessSDKVersion = applicationSDKVersion();
 
     parameters.latencyQOS = webProcessLatencyQOS();
     parameters.throughputQOS = webProcessThroughputQOS();
@@ -482,7 +481,6 @@
 void WebProcessPool::platformInitializeNetworkProcess(NetworkProcessCreationParameters& parameters)
 {
     parameters.uiProcessBundleIdentifier = applicationBundleIdentifier();
-    parameters.uiProcessSDKVersion = applicationSDKVersion();
 
     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
 

Modified: trunk/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm (275012 => 275013)


--- trunk/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm	2021-03-25 10:14:43 UTC (rev 275013)
@@ -27,6 +27,7 @@
 #import "ProcessLauncher.h"
 
 #import "WebPreferencesDefaultValues.h"
+#import <WebCore/RuntimeApplicationChecks.h>
 #import <crt_externs.h>
 #import <mach-o/dyld.h>
 #import <mach/mach_error.h>
@@ -39,6 +40,7 @@
 #import <wtf/RunLoop.h>
 #import <wtf/SoftLinking.h>
 #import <wtf/Threading.h>
+#import <wtf/cocoa/RuntimeApplicationChecksCocoa.h>
 #import <wtf/spi/cf/CFBundleSPI.h>
 #import <wtf/spi/darwin/XPCSPI.h>
 #import <wtf/text/CString.h>
@@ -207,6 +209,8 @@
     xpc_dictionary_set_mach_send(bootstrapMessage.get(), "server-port", listeningPort);
 
     xpc_dictionary_set_string(bootstrapMessage.get(), "client-identifier", !clientIdentifier.isEmpty() ? clientIdentifier.utf8().data() : *_NSGetProgname());
+    xpc_dictionary_set_string(bootstrapMessage.get(), "client-bundle-identifier", WebCore::applicationBundleIdentifier().utf8().data());
+    xpc_dictionary_set_string(bootstrapMessage.get(), "client-sdk-version", String::number(applicationSDKVersion()).utf8().data());
     xpc_dictionary_set_string(bootstrapMessage.get(), "process-identifier", String::number(m_launchOptions.processIdentifier.toUInt64()).utf8().data());
     xpc_dictionary_set_string(bootstrapMessage.get(), "ui-process-name", [[[NSProcessInfo processInfo] processName] UTF8String]);
     xpc_dictionary_set_string(bootstrapMessage.get(), "service-name", name);

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (275012 => 275013)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2021-03-25 10:14:43 UTC (rev 275013)
@@ -826,6 +826,7 @@
 
     parameters.memoryCacheDisabled = m_memoryCacheDisabled;
     parameters.attrStyleEnabled = m_configuration->attrStyleEnabled();
+    parameters.shouldThrowExceptionForGlobalConstantRedeclaration = m_configuration->shouldThrowExceptionForGlobalConstantRedeclaration();
 
 #if ENABLE(SERVICE_CONTROLS)
     auto& serviceController = ServicesController::singleton();

Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (275012 => 275013)


--- trunk/Source/WebKit/WebProcess/WebProcess.cpp	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp	2021-03-25 10:14:43 UTC (rev 275013)
@@ -484,6 +484,8 @@
     setMemoryCacheDisabled(parameters.memoryCacheDisabled);
 
     WebCore::RuntimeEnabledFeatures::sharedFeatures().setAttrStyleEnabled(parameters.attrStyleEnabled);
+    
+    commonVM().setGlobalConstRedeclarationShouldThrow(parameters.shouldThrowExceptionForGlobalConstantRedeclaration);
 
 #if ENABLE(SERVICE_CONTROLS)
     setEnabledServices(parameters.hasImageServices, parameters.hasSelectionServices, parameters.hasRichContentServices);

Modified: trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm (275012 => 275013)


--- trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2021-03-25 06:10:22 UTC (rev 275012)
+++ trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm	2021-03-25 10:14:43 UTC (rev 275013)
@@ -260,9 +260,6 @@
     WebKit::initializeLogChannelsIfNecessary(parameters.webKitLoggingChannels);
 #endif
 
-    WebCore::setApplicationBundleIdentifier(parameters.uiProcessBundleIdentifier);
-    setApplicationSDKVersion(parameters.uiProcessSDKVersion);
-
     m_uiProcessBundleIdentifier = parameters.uiProcessBundleIdentifier;
 
 #if ENABLE(SANDBOX_EXTENSIONS)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to