Changeset 241223 in webkit
- Timestamp:
- Feb 8, 2019 5:17:41 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r241205 r241223 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 Truitt Savell <tsavell@apple.com> 2 13 -
trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h
r241205 r241223 70 70 71 71 #define XPC_ARRAY_APPEND ((size_t)(-1)) 72 #define XPC_CONNECTION_MACH_SERVICE_LISTENER (1 << 0) 72 73 #define XPC_ERROR_CONNECTION_INVALID XPC_GLOBAL_OBJECT(_xpc_error_connection_invalid) 74 #define XPC_ERROR_KEY_DESCRIPTION _xpc_error_key_description 73 75 #define XPC_ERROR_TERMINATION_IMMINENT XPC_GLOBAL_OBJECT(_xpc_error_termination_imminent) 74 76 #define XPC_TYPE_ARRAY (&_xpc_type_array) … … 79 81 #define XPC_TYPE_ERROR (&_xpc_type_error) 80 82 #define XPC_TYPE_STRING (&_xpc_type_string) 83 84 extern const char * const _xpc_error_key_description; 81 85 82 86 #endif // PLATFORM(MAC) || USE(APPLE_INTERNAL_SDK) … … 153 157 void xpc_dictionary_set_mach_send(xpc_object_t, const char*, mach_port_t); 154 158 155 void xpc_connection_set_bootstrap(xpc_connection_t, xpc_object_t bootstrap);156 xpc_object_t xpc_copy_bootstrap(void);157 159 void xpc_connection_set_oneshot_instance(xpc_connection_t, uuid_t instance); 158 160 -
trunk/Source/WebKit/ChangeLog
r241205 r241223 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 Truitt Savell <tsavell@apple.com> 2 36 -
trunk/Source/WebKit/NetworkProcess/EntryPoint/Cocoa/Daemon/DaemonEntryPoint.mm
r241205 r241223 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
r241205 r241223 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
r241205 r241223 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 { 97 #if defined(__i386__) 98 // FIXME: This should only be done for the 32-bit plug-in XPC service so we rely on the fact that 99 // it's the only of the XPC services that are 32-bit. We should come up with a more targeted #if check. 100 @autoreleasepool { 101 // We must set the state of AppleMagnifiedMode before NSApplication initialization so that the value will be in 102 // place before Cocoa startup logic runs and caches the value. 103 [[NSUserDefaults standardUserDefaults] registerDefaults:@{ @"AppleMagnifiedMode" : @YES }]; 104 } 106 ASSERT(event); 107 ASSERT(xpc_get_type(event) == XPC_TYPE_DICTIONARY); 108 109 static std::once_flag once; 110 std::call_once(once, [event] { 111 #if PLATFORM(MAC) 112 // Don't allow Apple Events in WebKit processes. This can be removed when <rdar://problem/14012823> is fixed. 113 setenv("__APPLEEVENTSSERVICENAME", "", 1); 114 115 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 116 // We don't need to talk to the dock. 117 if (Class nsApplicationClass = NSClassFromString(@"NSApplication")) { 118 if ([nsApplicationClass respondsToSelector:@selector(_preventDockConnections)]) 119 [nsApplicationClass _preventDockConnections]; 120 } 121 #endif 105 122 #endif 106 123 107 auto bootstrap = adoptOSObject(xpc_copy_bootstrap()); 108 #if PLATFORM(IOS_FAMILY) 109 auto containerEnvironmentVariables = xpc_dictionary_get_value(bootstrap.get(), "ContainerEnvironmentVariables"); 110 xpc_dictionary_apply(containerEnvironmentVariables, ^(const char *key, xpc_object_t value) { 111 setenv(key, xpc_string_get_string_ptr(value), 1); 112 return true; 113 }); 124 #if defined(__i386__) 125 // FIXME: This should only be done for the 32-bit plug-in XPC service so we rely on the fact that 126 // it's the only of the XPC services that are 32-bit. We should come up with a more targeted #if check. 127 @autoreleasepool { 128 // We must set the state of AppleMagnifiedMode before NSApplication initialization so that the value will be in 129 // place before Cocoa startup logic runs and caches the value. 130 [[NSUserDefaults standardUserDefaults] registerDefaults:@{ @"AppleMagnifiedMode" : @YES }]; 131 } 114 132 #endif 115 133 116 if (bootstrap) { 134 #if PLATFORM(IOS_FAMILY) 135 auto containerEnvironmentVariables = xpc_dictionary_get_value(event, "ContainerEnvironmentVariables"); 136 xpc_dictionary_apply(containerEnvironmentVariables, ^(const char *key, xpc_object_t value) { 137 setenv(key, xpc_string_get_string_ptr(value), 1); 138 return true; 139 }); 140 #endif 141 117 142 #if PLATFORM(MAC) 118 if (const char* webKitBundleVersion = xpc_dictionary_get_string( bootstrap.get(), "WebKitBundleVersion")) {143 if (const char* webKitBundleVersion = xpc_dictionary_get_string(event, "WebKitBundleVersion")) { 119 144 CFBundleRef webKitBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebKit")); 120 145 NSString *expectedBundleVersion = (NSString *)CFBundleGetValueForInfoDictionaryKey(webKitBundle, kCFBundleVersionKey); … … 127 152 #endif 128 153 129 if (xpc_object_t languages = xpc_dictionary_get_value( bootstrap.get(), "OverrideLanguages")) {154 if (xpc_object_t languages = xpc_dictionary_get_value(event, "OverrideLanguages")) { 130 155 @autoreleasepool { 131 156 NSDictionary *existingArguments = [[NSUserDefaults standardUserDefaults] volatileDomainForName:NSArgumentDomain]; … … 140 165 } 141 166 } 142 } 167 }); 168 } 143 169 144 #if PLATFORM(MAC) 145 // Don't allow Apple Events in WebKit processes. This can be removed when <rdar://problem/14012823> is fixed. 146 setenv("__APPLEEVENTSSERVICENAME", "", 1); 147 148 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 149 // We don't need to talk to the dock. 150 if (Class nsApplicationClass = NSClassFromString(@"NSApplication")) { 151 if ([nsApplicationClass respondsToSelector:@selector(_preventDockConnections)]) 152 [nsApplicationClass _preventDockConnections]; 153 } 154 #endif 155 #endif 156 157 xpc_main(XPCServiceEventHandler); 170 int XPCServiceMain(int, const char**) 171 { 172 xpc_main([] (xpc_connection_t peer) { 173 XPCEventHandler(peer, AuxiliaryProcessType::XPCService); 174 }); 158 175 return 0; 159 176 } -
trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h
r241205 r241223 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
r241205 r241223 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
r241205 r241223 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
r241205 r241223 73 73 varname = "NETWORK_PROCESS_CMD_PREFIX"; 74 74 break; 75 case ProcessLauncher::ProcessType::NetworkDaemon: 76 ASSERT_NOT_REACHED(); 77 break; 75 78 } 76 79 const char* processCmdPrefix = getenv(varname); -
trunk/Source/WebKit/UIProcess/Launcher/ProcessLauncher.h
r241205 r241223 66 66 #endif 67 67 Network, 68 NetworkDaemon 68 69 }; 69 70 -
trunk/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm
r241205 r241223 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
r241205 r241223 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
r241205 r241223 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
r241205 r241223 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; } -
trunk/Tools/ChangeLog
r241221 r241223 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 * MiniBrowser/MiniBrowser.entitlements: 9 1 10 2019-02-08 Aakash Jain <aakash_jain@apple.com> 2 11 -
trunk/Tools/MiniBrowser/MiniBrowser.entitlements
r240805 r241223 8 8 <array> 9 9 <string>com.apple.Safari.SafeBrowsing.Service</string> 10 <string>com.apple.WebKit.NetworkingDaemon</string> 10 11 </array> 11 12 <key>com.apple.security.app-sandbox</key>
Note: See TracChangeset
for help on using the changeset viewer.