Title: [252083] trunk/Source/WebKit
Revision
252083
Author
pvol...@apple.com
Date
2019-11-05 14:22:17 -0800 (Tue, 05 Nov 2019)

Log Message

Eliminate mach lookup to cfprefsd on process startup
https://bugs.webkit.org/show_bug.cgi?id=202866

Reviewed by Geoffrey Garen.

Currently, the WebContent and Networking process is calling CFBundleGetValueForInfoDictionaryKey on startup
to get the entry point function name into the WebKit bundle. This causes a mach lookup to cfprefsd which
should be avoided. Instead, we can send the service name as part of the bootstrap message when the UI process
is starting the process, and have the new process read this value from the message on startup to determine
the name of the entry point. This is possibly also an improvement in launch time, since we avoid reading a
value from Info.plist.

* NetworkProcess/EntryPoint/Cocoa/XPCService/NetworkService/Info-OSX.plist:
* NetworkProcess/EntryPoint/Cocoa/XPCService/NetworkService/Info-iOS.plist:
* PluginProcess/EntryPoint/Cocoa/XPCService/PluginService.64.Info.plist:
* Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm:
(WebKit::XPCServiceEventHandler):
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):
* WebProcess/EntryPoint/Cocoa/XPCService/WebContentService/Info-OSX.plist:
* WebProcess/EntryPoint/Cocoa/XPCService/WebContentService/Info-iOS.plist:

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (252082 => 252083)


--- trunk/Source/WebKit/ChangeLog	2019-11-05 22:08:03 UTC (rev 252082)
+++ trunk/Source/WebKit/ChangeLog	2019-11-05 22:22:17 UTC (rev 252083)
@@ -1,5 +1,29 @@
 2019-11-05  Per Arne Vollan  <pvol...@apple.com>
 
+        Eliminate mach lookup to cfprefsd on process startup
+        https://bugs.webkit.org/show_bug.cgi?id=202866
+
+        Reviewed by Geoffrey Garen.
+
+        Currently, the WebContent and Networking process is calling CFBundleGetValueForInfoDictionaryKey on startup
+        to get the entry point function name into the WebKit bundle. This causes a mach lookup to cfprefsd which
+        should be avoided. Instead, we can send the service name as part of the bootstrap message when the UI process
+        is starting the process, and have the new process read this value from the message on startup to determine
+        the name of the entry point. This is possibly also an improvement in launch time, since we avoid reading a
+        value from Info.plist.
+
+        * NetworkProcess/EntryPoint/Cocoa/XPCService/NetworkService/Info-OSX.plist:
+        * NetworkProcess/EntryPoint/Cocoa/XPCService/NetworkService/Info-iOS.plist:
+        * PluginProcess/EntryPoint/Cocoa/XPCService/PluginService.64.Info.plist:
+        * Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm:
+        (WebKit::XPCServiceEventHandler):
+        * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
+        (WebKit::ProcessLauncher::launchProcess):
+        * WebProcess/EntryPoint/Cocoa/XPCService/WebContentService/Info-OSX.plist:
+        * WebProcess/EntryPoint/Cocoa/XPCService/WebContentService/Info-iOS.plist:
+
+2019-11-05  Per Arne Vollan  <pvol...@apple.com>
+
         [iOS] Add logging and telemetry to mach services believed to be unused
         https://bugs.webkit.org/show_bug.cgi?id=203831
 

Modified: trunk/Source/WebKit/NetworkProcess/EntryPoint/Cocoa/XPCService/NetworkService/Info-OSX.plist (252082 => 252083)


--- trunk/Source/WebKit/NetworkProcess/EntryPoint/Cocoa/XPCService/NetworkService/Info-OSX.plist	2019-11-05 22:08:03 UTC (rev 252082)
+++ trunk/Source/WebKit/NetworkProcess/EntryPoint/Cocoa/XPCService/NetworkService/Info-OSX.plist	2019-11-05 22:22:17 UTC (rev 252083)
@@ -26,8 +26,6 @@
 	<true/>
 	<key>NSPrincipalClass</key>
 	<string>NSApplication</string>
-	<key>WebKitEntryPoint</key>
-	<string>NetworkServiceInitializer</string>
 	<key>LSUIElement</key>
 	<true/>
 	<key>XPCService</key>

Modified: trunk/Source/WebKit/NetworkProcess/EntryPoint/Cocoa/XPCService/NetworkService/Info-iOS.plist (252082 => 252083)


--- trunk/Source/WebKit/NetworkProcess/EntryPoint/Cocoa/XPCService/NetworkService/Info-iOS.plist	2019-11-05 22:08:03 UTC (rev 252082)
+++ trunk/Source/WebKit/NetworkProcess/EntryPoint/Cocoa/XPCService/NetworkService/Info-iOS.plist	2019-11-05 22:22:17 UTC (rev 252083)
@@ -26,8 +26,6 @@
 	<true/>
 	<key>NSPrincipalClass</key>
 	<string>NSApplication</string>
-	<key>WebKitEntryPoint</key>
-	<string>NetworkServiceInitializer</string>
 	<key>LSUIElement</key>
 	<true/>
 	<key>XPCService</key>

Modified: trunk/Source/WebKit/NetworkProcess/EntryPoint/Cocoa/XPCService/NetworkServiceEntryPoint.mm (252082 => 252083)


--- trunk/Source/WebKit/NetworkProcess/EntryPoint/Cocoa/XPCService/NetworkServiceEntryPoint.mm	2019-11-05 22:08:03 UTC (rev 252082)
+++ trunk/Source/WebKit/NetworkProcess/EntryPoint/Cocoa/XPCService/NetworkServiceEntryPoint.mm	2019-11-05 22:22:17 UTC (rev 252083)
@@ -50,9 +50,9 @@
 
 using namespace WebKit;
 
-extern "C" WK_EXPORT void NetworkServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage);
+extern "C" WK_EXPORT void NETWORK_SERVICE_INITIALIZER(xpc_connection_t connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage);
 
-void NetworkServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage)
+void NETWORK_SERVICE_INITIALIZER(xpc_connection_t connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage)
 {
     WTF::initializeMainThread();
 

Modified: trunk/Source/WebKit/PluginProcess/EntryPoint/Cocoa/XPCService/PluginService.64.Info.plist (252082 => 252083)


--- trunk/Source/WebKit/PluginProcess/EntryPoint/Cocoa/XPCService/PluginService.64.Info.plist	2019-11-05 22:08:03 UTC (rev 252082)
+++ trunk/Source/WebKit/PluginProcess/EntryPoint/Cocoa/XPCService/PluginService.64.Info.plist	2019-11-05 22:22:17 UTC (rev 252083)
@@ -26,8 +26,6 @@
 	<false/>
 	<key>NSPrincipalClass</key>
 	<string>NSApplication</string>
-	<key>WebKitEntryPoint</key>
-	<string>PluginServiceInitializer</string>
 	<key>LSUIElement</key>
 	<true/>
 	<key>NSSupportsAutomaticGraphicsSwitching</key>

Modified: trunk/Source/WebKit/PluginProcess/EntryPoint/Cocoa/XPCService/PluginServiceEntryPoint.mm (252082 => 252083)


--- trunk/Source/WebKit/PluginProcess/EntryPoint/Cocoa/XPCService/PluginServiceEntryPoint.mm	2019-11-05 22:08:03 UTC (rev 252082)
+++ trunk/Source/WebKit/PluginProcess/EntryPoint/Cocoa/XPCService/PluginServiceEntryPoint.mm	2019-11-05 22:22:17 UTC (rev 252083)
@@ -69,9 +69,9 @@
 
 #endif // ENABLE(NETSCAPE_PLUGIN_API)
 
-extern "C" WK_EXPORT void PluginServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage);
+extern "C" WK_EXPORT void PLUGIN_SERVICE_INITIALIZER(xpc_connection_t connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage);
 
-void PluginServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage)
+void PLUGIN_SERVICE_INITIALIZER(xpc_connection_t connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage)
 {
 #if ENABLE(NETSCAPE_PLUGIN_API)
     WTF::initializeMainThread();

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


--- trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h	2019-11-05 22:08:03 UTC (rev 252082)
+++ trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h	2019-11-05 22:22:17 UTC (rev 252083)
@@ -39,6 +39,10 @@
 #endif
 #endif
 
+#define WEBCONTENT_SERVICE_INITIALIZER WebContentServiceInitializer
+#define NETWORK_SERVICE_INITIALIZER NetworkServiceInitializer
+#define PLUGIN_SERVICE_INITIALIZER PluginServiceInitializer
+
 namespace WebKit {
 
 class XPCServiceInitializerDelegate {

Modified: trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm (252082 => 252083)


--- trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm	2019-11-05 22:08:03 UTC (rev 252082)
+++ trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm	2019-11-05 22:22:17 UTC (rev 252083)
@@ -55,8 +55,19 @@
 
             if (!strcmp(xpc_dictionary_get_string(event, "message-name"), "bootstrap")) {
                 CFBundleRef webKitBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebKit"));
-                CFStringRef entryPointFunctionName = (CFStringRef)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), CFSTR("WebKitEntryPoint"));
 
+                const char* serviceName = xpc_dictionary_get_string(event, "service-name");
+                CFStringRef entryPointFunctionName = nullptr;
+                if (!strcmp(serviceName, "com.apple.WebKit.WebContent") || !strcmp(serviceName, "com.apple.WebKit.WebContent.Development"))
+                    entryPointFunctionName = CFSTR(STRINGIZE_VALUE_OF(WEBCONTENT_SERVICE_INITIALIZER));
+                else if (!strcmp(serviceName, "com.apple.WebKit.Networking"))
+                    entryPointFunctionName = CFSTR(STRINGIZE_VALUE_OF(NETWORK_SERVICE_INITIALIZER));
+                else if (!strcmp(serviceName, "com.apple.WebKit.Plugin.64"))
+                    entryPointFunctionName = CFSTR(STRINGIZE_VALUE_OF(PLUGIN_SERVICE_INITIALIZER));
+                else
+                    RELEASE_ASSERT_NOT_REACHED();
+
+                
                 typedef void (*InitializerFunction)(xpc_connection_t, xpc_object_t, xpc_object_t);
                 InitializerFunction initializerFunctionPtr = reinterpret_cast<InitializerFunction>(CFBundleGetFunctionPointerForName(webKitBundle, entryPointFunctionName));
                 if (!initializerFunctionPtr) {

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


--- trunk/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm	2019-11-05 22:08:03 UTC (rev 252082)
+++ trunk/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm	2019-11-05 22:22:17 UTC (rev 252083)
@@ -189,6 +189,7 @@
     xpc_dictionary_set_string(bootstrapMessage.get(), "client-identifier", !clientIdentifier.isEmpty() ? clientIdentifier.utf8().data() : *_NSGetProgname());
     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);
 
     bool isWebKitDevelopmentBuild = ![[[[NSBundle bundleWithIdentifier:@"com.apple.WebKit"] bundlePath] stringByDeletingLastPathComponent] hasPrefix:systemDirectoryPath()];
     if (isWebKitDevelopmentBuild) {

Modified: trunk/Source/WebKit/WebProcess/EntryPoint/Cocoa/XPCService/WebContentService/Info-OSX.plist (252082 => 252083)


--- trunk/Source/WebKit/WebProcess/EntryPoint/Cocoa/XPCService/WebContentService/Info-OSX.plist	2019-11-05 22:08:03 UTC (rev 252082)
+++ trunk/Source/WebKit/WebProcess/EntryPoint/Cocoa/XPCService/WebContentService/Info-OSX.plist	2019-11-05 22:22:17 UTC (rev 252083)
@@ -28,8 +28,6 @@
 	<true/>
 	<key>NSPrincipalClass</key>
 	<string>NSApplication</string>
-	<key>WebKitEntryPoint</key>
-	<string>WebContentServiceInitializer</string>
 	<key>LSUIElement</key>
 	<true/>
 	<key>NSSupportsAutomaticGraphicsSwitching</key>

Modified: trunk/Source/WebKit/WebProcess/EntryPoint/Cocoa/XPCService/WebContentService/Info-iOS.plist (252082 => 252083)


--- trunk/Source/WebKit/WebProcess/EntryPoint/Cocoa/XPCService/WebContentService/Info-iOS.plist	2019-11-05 22:08:03 UTC (rev 252082)
+++ trunk/Source/WebKit/WebProcess/EntryPoint/Cocoa/XPCService/WebContentService/Info-iOS.plist	2019-11-05 22:22:17 UTC (rev 252083)
@@ -26,8 +26,6 @@
 	<string>${BUNDLE_VERSION}</string>
 	<key>LSFileQuarantineEnabled</key>
 	<true/>
-	<key>WebKitEntryPoint</key>
-	<string>WebContentServiceInitializer</string>
 	<key>XPCService</key>
 	<dict>
 		<key>ServiceType</key>

Modified: trunk/Source/WebKit/WebProcess/EntryPoint/Cocoa/XPCService/WebContentServiceEntryPoint.mm (252082 => 252083)


--- trunk/Source/WebKit/WebProcess/EntryPoint/Cocoa/XPCService/WebContentServiceEntryPoint.mm	2019-11-05 22:08:03 UTC (rev 252082)
+++ trunk/Source/WebKit/WebProcess/EntryPoint/Cocoa/XPCService/WebContentServiceEntryPoint.mm	2019-11-05 22:22:17 UTC (rev 252083)
@@ -35,9 +35,9 @@
 #import <pal/spi/ios/GraphicsServicesSPI.h>
 #endif
 
-extern "C" WK_EXPORT void WebContentServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage);
+extern "C" WK_EXPORT void WEBCONTENT_SERVICE_INITIALIZER(xpc_connection_t connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage);
 
-void WebContentServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage)
+void WEBCONTENT_SERVICE_INITIALIZER(xpc_connection_t connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage)
 {
     WTF::initializeMainThread();
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to