Changeset 241197 in webkit
- Timestamp:
- Feb 8, 2019 9:18:08 AM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r241192 r241197 1 2019-02-08 Alex Christensen <achristensen@webkit.org> 2 3 Add SPI to use networking daemon instead of XPC service 4 https://bugs.webkit.org/show_bug.cgi?id=194427 5 6 Reviewed by Geoffrey Garen. 7 8 * wtf/spi/darwin/XPCSPI.h: 9 Instead of using XPC bootstrap SPI, we just send a separate message. 10 xpc_copy_bootstrap does not seem to work in daemons. 11 1 12 2019-02-08 Benjamin Poulain <benjamin@webkit.org> 2 13 -
trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h
r237266 r241197 153 153 void xpc_dictionary_set_mach_send(xpc_object_t, const char*, mach_port_t); 154 154 155 void xpc_connection_set_bootstrap(xpc_connection_t, xpc_object_t bootstrap);156 xpc_object_t xpc_copy_bootstrap(void);157 155 void xpc_connection_set_oneshot_instance(xpc_connection_t, uuid_t instance); 158 156 … … 182 180 183 181 WTF_EXTERN_C_END 182 183 #define XPC_CONNECTION_MACH_SERVICE_LISTENER (1 << 0) -
trunk/Source/WebKit/ChangeLog
r241191 r241197 1 2019-02-08 Alex Christensen <achristensen@webkit.org> 2 3 Add SPI to use networking daemon instead of XPC service 4 https://bugs.webkit.org/show_bug.cgi?id=194427 5 6 Reviewed by Geoffrey Garen. 7 8 There is still work to be done, but with the proper plist it starts and loads webpages! 9 10 * NetworkProcess/EntryPoint/Cocoa/Daemon/DaemonEntryPoint.mm: 11 (WebKit::DaemonMain): 12 * Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h: 13 * Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm: 14 (WebKit::XPCEventHandler): 15 (WebKit::XPCInitializationHandler): 16 (WebKit::XPCServiceMain): 17 (WebKit::XPCServiceEventHandler): Deleted. 18 * UIProcess/API/APIProcessPoolConfiguration.h: 19 * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h: 20 * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm: 21 (-[_WKProcessPoolConfiguration usesNetworkingDaemon]): 22 (-[_WKProcessPoolConfiguration setUsesNetworkingDaemon:]): 23 * UIProcess/AuxiliaryProcessProxy.cpp: 24 (WebKit::AuxiliaryProcessProxy::getLaunchOptions): 25 * UIProcess/Launcher/ProcessLauncher.h: 26 * UIProcess/Launcher/mac/ProcessLauncherMac.mm: 27 (WebKit::serviceName): 28 (WebKit::ProcessLauncher::launchProcess): 29 * UIProcess/Network/NetworkProcessProxy.cpp: 30 (WebKit::NetworkProcessProxy::getLaunchOptions): 31 * UIProcess/WebProcessPool.cpp: 32 (WebKit::WebProcessPool::usesNetworkingDaemon const): 33 * UIProcess/WebProcessPool.h: 34 1 35 2019-02-08 Keith Rollin <krollin@apple.com> 2 36 -
trunk/Source/WebKit/NetworkProcess/EntryPoint/Cocoa/Daemon/DaemonEntryPoint.mm
r240973 r241197 27 27 #import "DaemonEntryPoint.h" 28 28 29 #import "XPCServiceEntryPoint.h" 30 #import <wtf/spi/darwin/XPCSPI.h> 31 29 32 namespace WebKit { 33 34 int DaemonMain(int argc, const char** argv) 35 { 36 if (argc < 2 || strcmp(argv[1], "WebKitNetworkingDaemon")) { 37 WTFLogAlways("Unexpected daemon parameters"); 38 return EXIT_FAILURE; 39 } 30 40 31 int DaemonMain(int, const char**) 32 { 33 return 0; 41 xpc_connection_t listener = xpc_connection_create_mach_service("com.apple.WebKit.NetworkingDaemon", dispatch_get_main_queue(), XPC_CONNECTION_MACH_SERVICE_LISTENER); 42 43 xpc_connection_set_event_handler(listener, ^(xpc_object_t peer) { 44 if (!peer || xpc_get_type(peer) != XPC_TYPE_CONNECTION) { 45 WTFLogAlways("Unexpected XPC object"); 46 return; 47 } 48 49 XPCEventHandler(peer, AuxiliaryProcessType::Daemon); 50 }); 51 52 xpc_connection_resume(listener); 53 CFRunLoopRun(); 54 55 return EXIT_SUCCESS; 34 56 } 35 57 -
trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h
r240683 r241197 131 131 int XPCServiceMain(int, const char**); 132 132 133 enum class AuxiliaryProcessType { Daemon, XPCService }; 134 void XPCEventHandler(xpc_connection_t, AuxiliaryProcessType); 135 133 136 void XPCServiceExit(OSObjectPtr<xpc_object_t>&& priorityBoostMessage); 134 137 -
trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm
r240956 r241197 39 39 namespace WebKit { 40 40 41 static void XPCServiceEventHandler(xpc_connection_t peer) 41 void XPCInitializationHandler(xpc_object_t); 42 43 void XPCEventHandler(xpc_connection_t peer, AuxiliaryProcessType processType) 42 44 { 43 45 static xpc_object_t priorityBoostMessage = nullptr; … … 48 50 if (type == XPC_TYPE_ERROR) { 49 51 if (event == XPC_ERROR_CONNECTION_INVALID || event == XPC_ERROR_TERMINATION_IMMINENT) { 50 // FIXME: Handle this case more gracefully. 51 exit(EXIT_FAILURE); 52 if (processType == AuxiliaryProcessType::XPCService) { 53 // FIXME: Handle this case more gracefully. 54 exit(EXIT_FAILURE); 55 } else { 56 // FIXME: Deref the NetworkProcess object associated with this xpc connection 57 // once we have a container for such objects. 58 } 52 59 } 53 60 } else { … … 55 62 56 63 if (!strcmp(xpc_dictionary_get_string(event, "message-name"), "bootstrap")) { 64 XPCInitializationHandler(xpc_dictionary_get_value(event, "initialization-message")); 65 57 66 CFBundleRef webKitBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebKit")); 58 67 CFStringRef entryPointFunctionName = (CFStringRef)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), CFSTR("WebKitEntryPoint")); … … 93 102 } 94 103 95 int XPCServiceMain(int, const char**)104 void XPCInitializationHandler(xpc_object_t event) 96 105 { 106 ASSERT(event); 107 ASSERT(xpc_get_type(event) == XPC_TYPE_DICTIONARY); 97 108 #if defined(__i386__) 98 109 // FIXME: This should only be done for the 32-bit plug-in XPC service so we rely on the fact that … … 105 116 #endif 106 117 107 auto bootstrap = adoptOSObject(xpc_copy_bootstrap());108 118 #if PLATFORM(IOS_FAMILY) 109 auto containerEnvironmentVariables = xpc_dictionary_get_value( bootstrap.get(), "ContainerEnvironmentVariables");119 auto containerEnvironmentVariables = xpc_dictionary_get_value(event, "ContainerEnvironmentVariables"); 110 120 xpc_dictionary_apply(containerEnvironmentVariables, ^(const char *key, xpc_object_t value) { 111 121 setenv(key, xpc_string_get_string_ptr(value), 1); … … 114 124 #endif 115 125 116 if (bootstrap) {117 126 #if PLATFORM(MAC) 118 if (const char* webKitBundleVersion = xpc_dictionary_get_string(bootstrap.get(), "WebKitBundleVersion")) {119 120 127 if (const char* webKitBundleVersion = xpc_dictionary_get_string(event, "WebKitBundleVersion")) { 128 CFBundleRef webKitBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebKit")); 129 NSString *expectedBundleVersion = (NSString *)CFBundleGetValueForInfoDictionaryKey(webKitBundle, kCFBundleVersionKey); 121 130 122 if (strcmp(webKitBundleVersion, expectedBundleVersion.UTF8String)) { 123 _WKSetCrashReportApplicationSpecificInformation([NSString stringWithFormat:@"WebKit framework version mismatch: '%s'", webKitBundleVersion]); 124 __builtin_trap(); 125 } 131 if (strcmp(webKitBundleVersion, expectedBundleVersion.UTF8String)) { 132 _WKSetCrashReportApplicationSpecificInformation([NSString stringWithFormat:@"WebKit framework version mismatch: '%s'", webKitBundleVersion]); 133 __builtin_trap(); 126 134 } 135 } 127 136 #endif 128 137 129 if (xpc_object_t languages = xpc_dictionary_get_value(bootstrap.get(), "OverrideLanguages")) { 130 @autoreleasepool { 131 NSDictionary *existingArguments = [[NSUserDefaults standardUserDefaults] volatileDomainForName:NSArgumentDomain]; 132 NSMutableDictionary *newArguments = [existingArguments mutableCopy]; 133 RetainPtr<NSMutableArray> newLanguages = adoptNS([[NSMutableArray alloc] init]); 134 xpc_array_apply(languages, ^(size_t index, xpc_object_t value) { 135 [newLanguages addObject:[NSString stringWithCString:xpc_string_get_string_ptr(value) encoding:NSUTF8StringEncoding]]; 136 return true; 137 }); 138 [newArguments setValue:newLanguages.get() forKey:@"AppleLanguages"]; 139 [[NSUserDefaults standardUserDefaults] setVolatileDomain:newArguments forName:NSArgumentDomain]; 140 } 138 if (xpc_object_t languages = xpc_dictionary_get_value(event, "OverrideLanguages")) { 139 @autoreleasepool { 140 NSDictionary *existingArguments = [[NSUserDefaults standardUserDefaults] volatileDomainForName:NSArgumentDomain]; 141 NSMutableDictionary *newArguments = [existingArguments mutableCopy]; 142 RetainPtr<NSMutableArray> newLanguages = adoptNS([[NSMutableArray alloc] init]); 143 xpc_array_apply(languages, ^(size_t index, xpc_object_t value) { 144 [newLanguages addObject:[NSString stringWithCString:xpc_string_get_string_ptr(value) encoding:NSUTF8StringEncoding]]; 145 return true; 146 }); 147 [newArguments setValue:newLanguages.get() forKey:@"AppleLanguages"]; 148 [[NSUserDefaults standardUserDefaults] setVolatileDomain:newArguments forName:NSArgumentDomain]; 141 149 } 142 150 } … … 154 162 #endif 155 163 #endif 164 } 156 165 157 xpc_main(XPCServiceEventHandler); 166 int XPCServiceMain(int, const char**) 167 { 168 xpc_main([] (xpc_connection_t peer) { 169 XPCEventHandler(peer, AuxiliaryProcessType::XPCService); 170 }); 158 171 return 0; 159 172 } -
trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h
r240363 r241197 183 183 bool suppressesConnectionTerminationOnSystemChange() const { return m_suppressesConnectionTerminationOnSystemChange; } 184 184 void setSuppressesConnectionTerminationOnSystemChange(bool suppressesConnectionTerminationOnSystemChange) { m_suppressesConnectionTerminationOnSystemChange = suppressesConnectionTerminationOnSystemChange; } 185 186 bool usesNetworkingDaemon() const { return m_usesNetworkingDaemon; } 187 void setUsesNetworkingDaemon(bool usesNetworkingDaemon) { m_usesNetworkingDaemon = usesNetworkingDaemon; } 185 188 #endif 186 189 … … 236 239 #if PLATFORM(COCOA) 237 240 bool m_suppressesConnectionTerminationOnSystemChange { false }; 241 bool m_usesNetworkingDaemon { false }; 238 242 #endif 239 243 }; -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h
r240363 r241197 71 71 @property (nonatomic) BOOL suppressesConnectionTerminationOnSystemChange WK_API_AVAILABLE(macosx(10.14), ios(12.0)); 72 72 @property (nonatomic, getter=isJITEnabled) BOOL JITEnabled WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); 73 @property (nonatomic) BOOL usesNetworkingDaemon WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA)); 73 74 74 75 @end -
trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm
r240363 r241197 317 317 } 318 318 319 - (BOOL)usesNetworkingDaemon 320 { 321 return _processPoolConfiguration->usesNetworkingDaemon(); 322 } 323 324 - (void)setUsesNetworkingDaemon:(BOOL)enabled 325 { 326 _processPoolConfiguration->setUsesNetworkingDaemon(enabled); 327 } 328 329 319 330 - (void)setSuppressesConnectionTerminationOnSystemChange:(BOOL)suppressesConnectionTerminationOnSystemChange 320 331 { -
trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp
r240683 r241197 73 73 varname = "NETWORK_PROCESS_CMD_PREFIX"; 74 74 break; 75 case ProcessLauncher::ProcessType::NetworkDaemon: 76 ASSERT_NOT_REACHED(); 75 77 } 76 78 const char* processCmdPrefix = getenv(varname); -
trunk/Source/WebKit/UIProcess/Launcher/ProcessLauncher.h
r240640 r241197 66 66 #endif 67 67 Network, 68 NetworkDaemon 68 69 }; 69 70 -
trunk/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm
r238388 r241197 57 57 case ProcessLauncher::ProcessType::Network: 58 58 return "com.apple.WebKit.Networking"; 59 case ProcessLauncher::ProcessType::NetworkDaemon: 60 ASSERT_NOT_REACHED(); 61 return nullptr; 59 62 #if ENABLE(NETSCAPE_PLUGIN_API) 60 63 case ProcessLauncher::ProcessType::Plugin32: … … 96 99 ASSERT(!m_xpcConnection); 97 100 98 const char* name; 99 if (!m_launchOptions.customWebContentServiceBundleIdentifier.isNull()) 100 name = m_launchOptions.customWebContentServiceBundleIdentifier.data(); 101 else 102 name = serviceName(m_launchOptions); 103 104 m_xpcConnection = adoptOSObject(xpc_connection_create(name, nullptr)); 105 106 uuid_t uuid; 107 uuid_generate(uuid); 108 xpc_connection_set_oneshot_instance(m_xpcConnection.get(), uuid); 101 if (m_launchOptions.processType == ProcessLauncher::ProcessType::NetworkDaemon) 102 m_xpcConnection = adoptOSObject(xpc_connection_create_mach_service("com.apple.WebKit.NetworkingDaemon", dispatch_get_main_queue(), 0)); 103 else { 104 const char* name = m_launchOptions.customWebContentServiceBundleIdentifier.isNull() ? serviceName(m_launchOptions) : m_launchOptions.customWebContentServiceBundleIdentifier.data(); 105 m_xpcConnection = adoptOSObject(xpc_connection_create(name, nullptr)); 106 107 uuid_t uuid; 108 uuid_generate(uuid); 109 xpc_connection_set_oneshot_instance(m_xpcConnection.get(), uuid); 110 } 109 111 110 112 // Inherit UI process localization. It can be different from child process default localization: … … 137 139 xpc_dictionary_set_string(initializationMessage.get(), "WebKitBundleVersion", [[NSBundle bundleWithIdentifier:@"com.apple.WebKit"].infoDictionary[(__bridge NSString *)kCFBundleVersionKey] UTF8String]); 138 140 #endif 139 xpc_connection_set_bootstrap(m_xpcConnection.get(), initializationMessage.get());140 141 141 142 if (shouldLeakBoost(m_launchOptions)) { … … 172 173 clientIdentifier = [[NSBundle mainBundle] bundleIdentifier]; 173 174 174 // FIXME: Switch to xpc_connection_set_bootstrap once it's available everywhere we need.175 175 auto bootstrapMessage = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0)); 176 177 xpc_dictionary_set_value(bootstrapMessage.get(), "initialization-message", initializationMessage.get()); 176 178 177 179 if (m_client && !m_client->isJITEnabled()) … … 201 203 auto errorHandlerImpl = [weakProcessLauncher = makeWeakPtr(*this), listeningPort] (xpc_object_t event) { 202 204 ASSERT(!event || xpc_get_type(event) == XPC_TYPE_ERROR); 205 206 if (event) 207 LOG_ERROR("Error launching auxiliary process: %s", xpc_dictionary_get_string(event, XPC_ERROR_KEY_DESCRIPTION)); 203 208 204 209 auto processLauncher = weakProcessLauncher.get(); -
trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
r240687 r241197 103 103 void NetworkProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& launchOptions) 104 104 { 105 launchOptions.processType = ProcessLauncher::ProcessType::Network;105 launchOptions.processType = m_processPool.usesNetworkingDaemon() ? ProcessLauncher::ProcessType::NetworkDaemon : ProcessLauncher::ProcessType::Network; 106 106 AuxiliaryProcessProxy::getLaunchOptions(launchOptions); 107 107 -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r240725 r241197 1508 1508 } 1509 1509 1510 bool WebProcessPool::usesNetworkingDaemon() const 1511 { 1512 #if PLATFORM(COCOA) 1513 return m_configuration->usesNetworkingDaemon(); 1514 #else 1515 return false; 1516 #endif 1517 } 1518 1510 1519 void WebProcessPool::setCacheModel(CacheModel cacheModel) 1511 1520 { -
trunk/Source/WebKit/UIProcess/WebProcessPool.h
r240725 r241197 256 256 API::DownloadClient& downloadClient() { return *m_downloadClient; } 257 257 258 bool usesNetworkingDaemon() const; 259 258 260 API::LegacyContextHistoryClient& historyClient() { return *m_historyClient; } 259 261 WebContextClient& client() { return m_client; }
Note: See TracChangeset
for help on using the changeset viewer.