Changeset 242303 in webkit


Ignore:
Timestamp:
Mar 1, 2019 6:29:40 PM (5 years ago)
Author:
achristensen@apple.com
Message:

Revert r241223, r241235, and r241287
https://bugs.webkit.org/show_bug.cgi?id=194427
<rdar://48045861>

Source/WebKit:

This caused crashes, and feature design has evolved away from needing the daemon in this form.

  • NetworkProcess/EntryPoint/Cocoa/Daemon/DaemonEntryPoint.mm:

(WebKit::DaemonMain):

  • Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h:
  • Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm:

(WebKit::XPCServiceEventHandler):
(WebKit::XPCServiceMain):
(WebKit::XPCEventHandler): Deleted.
(WebKit::XPCInitializationHandler): Deleted.

  • UIProcess/API/APIProcessPoolConfiguration.h:
  • UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
  • UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:

(-[_WKProcessPoolConfiguration usesNetworkingDaemon]): Deleted.
(-[_WKProcessPoolConfiguration setUsesNetworkingDaemon:]): Deleted.

  • UIProcess/AuxiliaryProcessProxy.cpp:

(WebKit::AuxiliaryProcessProxy::getLaunchOptions):

  • UIProcess/Launcher/ProcessLauncher.h:
  • UIProcess/Launcher/mac/ProcessLauncherMac.mm:

(WebKit::serviceName):
(WebKit::ProcessLauncher::launchProcess):

  • UIProcess/Network/NetworkProcessProxy.cpp:

(WebKit::NetworkProcessProxy::getLaunchOptions):

  • UIProcess/WebProcessPool.cpp:

(WebKit::WebProcessPool::usesNetworkingDaemon const): Deleted.

  • UIProcess/WebProcessPool.h:

Source/WTF:

  • wtf/spi/darwin/XPCSPI.h:
Location:
trunk/Source
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r242294 r242303  
     12019-03-01  Alex Christensen  <achristensen@webkit.org>
     2
     3        Revert r241223, r241235, and r241287
     4        https://bugs.webkit.org/show_bug.cgi?id=194427
     5        <rdar://48045861>
     6
     7        * wtf/spi/darwin/XPCSPI.h:
     8
    192019-03-01  Simon Fraser  <simon.fraser@apple.com>
    210
  • trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h

    r241223 r242303  
    157157void xpc_dictionary_set_mach_send(xpc_object_t, const char*, mach_port_t);
    158158
     159void xpc_connection_set_bootstrap(xpc_connection_t, xpc_object_t);
     160xpc_object_t xpc_copy_bootstrap();
    159161void xpc_connection_set_oneshot_instance(xpc_connection_t, uuid_t instance);
    160162
  • trunk/Source/WebKit/ChangeLog

    r242302 r242303  
     12019-03-01  Alex Christensen  <achristensen@webkit.org>
     2
     3        Revert r241223, r241235, and r241287
     4        https://bugs.webkit.org/show_bug.cgi?id=194427
     5        <rdar://48045861>
     6
     7        This caused crashes, and feature design has evolved away from needing the daemon in this form.
     8
     9        * NetworkProcess/EntryPoint/Cocoa/Daemon/DaemonEntryPoint.mm:
     10        (WebKit::DaemonMain):
     11        * Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h:
     12        * Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm:
     13        (WebKit::XPCServiceEventHandler):
     14        (WebKit::XPCServiceMain):
     15        (WebKit::XPCEventHandler): Deleted.
     16        (WebKit::XPCInitializationHandler): Deleted.
     17        * UIProcess/API/APIProcessPoolConfiguration.h:
     18        * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h:
     19        * UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm:
     20        (-[_WKProcessPoolConfiguration usesNetworkingDaemon]): Deleted.
     21        (-[_WKProcessPoolConfiguration setUsesNetworkingDaemon:]): Deleted.
     22        * UIProcess/AuxiliaryProcessProxy.cpp:
     23        (WebKit::AuxiliaryProcessProxy::getLaunchOptions):
     24        * UIProcess/Launcher/ProcessLauncher.h:
     25        * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
     26        (WebKit::serviceName):
     27        (WebKit::ProcessLauncher::launchProcess):
     28        * UIProcess/Network/NetworkProcessProxy.cpp:
     29        (WebKit::NetworkProcessProxy::getLaunchOptions):
     30        * UIProcess/WebProcessPool.cpp:
     31        (WebKit::WebProcessPool::usesNetworkingDaemon const): Deleted.
     32        * UIProcess/WebProcessPool.h:
     33
    1342019-03-01  Alex Christensen  <achristensen@webkit.org>
    235
  • trunk/Source/WebKit/NetworkProcess/EntryPoint/Cocoa/Daemon/DaemonEntryPoint.mm

    r241223 r242303  
    2727#import "DaemonEntryPoint.h"
    2828
    29 #import "XPCServiceEntryPoint.h"
    30 #import <wtf/spi/darwin/XPCSPI.h>
    31 
    3229namespace WebKit {
    3330   
    34 int DaemonMain(int argc, const char** argv)
     31int DaemonMain(int, const char**)
    3532{
    36     if (argc < 2 || strcmp(argv[1], "WebKitNetworkingDaemon")) {
    37         WTFLogAlways("Unexpected daemon parameters");
    38         return EXIT_FAILURE;
    39     }
    40 
    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;
     33    return 0;
    5634}
    5735
  • trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceEntryPoint.h

    r241223 r242303  
    131131int XPCServiceMain(int, const char**);
    132132
    133 enum class AuxiliaryProcessType { Daemon, XPCService };
    134 void XPCEventHandler(xpc_connection_t, AuxiliaryProcessType);
    135 
    136133void XPCServiceExit(OSObjectPtr<xpc_object_t>&& priorityBoostMessage);
    137134
  • trunk/Source/WebKit/Shared/EntryPointUtilities/Cocoa/XPCService/XPCServiceMain.mm

    r241235 r242303  
    3939namespace WebKit {
    4040
    41 void XPCInitializationHandler(xpc_object_t);
    42 
    43 void XPCEventHandler(xpc_connection_t peer, AuxiliaryProcessType processType)
     41static void XPCServiceEventHandler(xpc_connection_t peer)
    4442{
    4543    static xpc_object_t priorityBoostMessage = nullptr;
     
    5048        if (type == XPC_TYPE_ERROR) {
    5149            if (event == XPC_ERROR_CONNECTION_INVALID || event == XPC_ERROR_TERMINATION_IMMINENT) {
    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                 }
     50                // FIXME: Handle this case more gracefully.
     51                exit(EXIT_FAILURE);
    5952            }
    6053        } else {
     
    6255
    6356            if (!strcmp(xpc_dictionary_get_string(event, "message-name"), "bootstrap")) {
    64                 XPCInitializationHandler(xpc_dictionary_get_value(event, "initialization-message"));
    65                
    6657                CFBundleRef webKitBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebKit"));
    6758                CFStringRef entryPointFunctionName = (CFStringRef)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), CFSTR("WebKitEntryPoint"));
     
    10293}
    10394
    104 void XPCInitializationHandler(xpc_object_t event)
     95int XPCServiceMain(int, const char**)
    10596{
    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] {
    11197#if defined(__i386__)
    112         // FIXME: This should only be done for the 32-bit plug-in XPC service so we rely on the fact that
    113         // it's the only of the XPC services that are 32-bit. We should come up with a more targeted #if check.
    114         @autoreleasepool {
    115             // We must set the state of AppleMagnifiedMode before NSApplication initialization so that the value will be in
    116             // place before Cocoa startup logic runs and caches the value.
    117             [[NSUserDefaults standardUserDefaults] registerDefaults:@{ @"AppleMagnifiedMode" : @YES }];
    118         }
     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    }
    119105#endif
    120106
     107    auto bootstrap = adoptOSObject(xpc_copy_bootstrap());
    121108#if PLATFORM(IOS_FAMILY)
    122         auto containerEnvironmentVariables = xpc_dictionary_get_value(event, "ContainerEnvironmentVariables");
    123         xpc_dictionary_apply(containerEnvironmentVariables, ^(const char *key, xpc_object_t value) {
    124             setenv(key, xpc_string_get_string_ptr(value), 1);
    125             return true;
    126         });
     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    });
    127114#endif
    128115
     116    if (bootstrap) {
    129117#if PLATFORM(MAC)
    130         if (const char* webKitBundleVersion = xpc_dictionary_get_string(event, "WebKitBundleVersion")) {
     118        if (const char* webKitBundleVersion = xpc_dictionary_get_string(bootstrap.get(), "WebKitBundleVersion")) {
    131119            CFBundleRef webKitBundle = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.WebKit"));
    132120            NSString *expectedBundleVersion = (NSString *)CFBundleGetValueForInfoDictionaryKey(webKitBundle, kCFBundleVersionKey);
     
    139127#endif
    140128
    141         if (xpc_object_t languages = xpc_dictionary_get_value(event, "OverrideLanguages")) {
     129        if (xpc_object_t languages = xpc_dictionary_get_value(bootstrap.get(), "OverrideLanguages")) {
    142130            @autoreleasepool {
    143131                NSDictionary *existingArguments = [[NSUserDefaults standardUserDefaults] volatileDomainForName:NSArgumentDomain];
     
    152140            }
    153141        }
    154     });
    155 }
     142    }
    156143
    157 int XPCServiceMain(int, const char**)
    158 {
    159144#if PLATFORM(MAC)
    160145    // Don't allow Apple Events in WebKit processes. This can be removed when <rdar://problem/14012823> is fixed.
    161146    setenv("__APPLEEVENTSSERVICENAME", "", 1);
    162    
     147
    163148#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400
    164149    // We don't need to talk to the dock.
     
    170155#endif
    171156
    172     xpc_main([] (xpc_connection_t peer) {
    173         XPCEventHandler(peer, AuxiliaryProcessType::XPCService);
    174     });
     157    xpc_main(XPCServiceEventHandler);
    175158    return 0;
    176159}
  • trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h

    r241556 r242303  
    186186    bool suppressesConnectionTerminationOnSystemChange() const { return m_suppressesConnectionTerminationOnSystemChange; }
    187187    void setSuppressesConnectionTerminationOnSystemChange(bool suppressesConnectionTerminationOnSystemChange) { m_suppressesConnectionTerminationOnSystemChange = suppressesConnectionTerminationOnSystemChange; }
    188 
    189     bool usesNetworkingDaemon() const { return m_usesNetworkingDaemon; }
    190     void setUsesNetworkingDaemon(bool usesNetworkingDaemon) { m_usesNetworkingDaemon = usesNetworkingDaemon; }
    191188#endif
    192189
     
    243240#if PLATFORM(COCOA)
    244241    bool m_suppressesConnectionTerminationOnSystemChange { false };
    245     bool m_usesNetworkingDaemon { false };
    246242#endif
    247243};
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.h

    r241556 r242303  
    7272@property (nonatomic) BOOL suppressesConnectionTerminationOnSystemChange WK_API_AVAILABLE(macosx(10.14), ios(12.0));
    7373@property (nonatomic, getter=isJITEnabled) BOOL JITEnabled WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    74 @property (nonatomic) BOOL usesNetworkingDaemon WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    7574
    7675@end
  • trunk/Source/WebKit/UIProcess/API/Cocoa/_WKProcessPoolConfiguration.mm

    r241556 r242303  
    327327}
    328328
    329 - (BOOL)usesNetworkingDaemon
    330 {
    331     return _processPoolConfiguration->usesNetworkingDaemon();
    332 }
    333 
    334 - (void)setUsesNetworkingDaemon:(BOOL)enabled
    335 {
    336     _processPoolConfiguration->setUsesNetworkingDaemon(enabled);
    337 }
    338 
    339 
    340329- (void)setSuppressesConnectionTerminationOnSystemChange:(BOOL)suppressesConnectionTerminationOnSystemChange
    341330{
  • trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.cpp

    r241654 r242303  
    7373        varname = "NETWORK_PROCESS_CMD_PREFIX";
    7474        break;
    75     case ProcessLauncher::ProcessType::NetworkDaemon:
    76         ASSERT_NOT_REACHED();
    77         break;
    7875    }
    7976    const char* processCmdPrefix = getenv(varname);
  • trunk/Source/WebKit/UIProcess/Launcher/ProcessLauncher.h

    r241223 r242303  
    6565        Plugin64,
    6666#endif
    67         Network,
    68         NetworkDaemon
     67        Network
    6968    };
    7069
  • trunk/Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm

    r241654 r242303  
    5757    case ProcessLauncher::ProcessType::Network:
    5858        return "com.apple.WebKit.Networking";
    59     case ProcessLauncher::ProcessType::NetworkDaemon:
    60         ASSERT_NOT_REACHED();
    61         return nullptr;
    6259#if ENABLE(NETSCAPE_PLUGIN_API)
    6360    case ProcessLauncher::ProcessType::Plugin32:
     
    9996    ASSERT(!m_xpcConnection);
    10097
    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     }
     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);
    111109
    112110    // Inherit UI process localization. It can be different from child process default localization:
     
    139137    xpc_dictionary_set_string(initializationMessage.get(), "WebKitBundleVersion", [[NSBundle bundleWithIdentifier:@"com.apple.WebKit"].infoDictionary[(__bridge NSString *)kCFBundleVersionKey] UTF8String]);
    140138#endif
     139    xpc_connection_set_bootstrap(m_xpcConnection.get(), initializationMessage.get());
    141140
    142141    if (shouldLeakBoost(m_launchOptions)) {
     
    173172        clientIdentifier = [[NSBundle mainBundle] bundleIdentifier];
    174173
     174    // FIXME: Switch to xpc_connection_set_bootstrap once it's available everywhere we need.
    175175    auto bootstrapMessage = adoptOSObject(xpc_dictionary_create(nullptr, nullptr, 0));
    176 
    177     xpc_dictionary_set_value(bootstrapMessage.get(), "initialization-message", initializationMessage.get());
    178176   
    179177    if (m_client && !m_client->isJITEnabled())
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp

    r242288 r242303  
    104104void NetworkProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& launchOptions)
    105105{
    106     launchOptions.processType = m_processPool.usesNetworkingDaemon() ? ProcessLauncher::ProcessType::NetworkDaemon : ProcessLauncher::ProcessType::Network;
     106    launchOptions.processType = ProcessLauncher::ProcessType::Network;
    107107    AuxiliaryProcessProxy::getLaunchOptions(launchOptions);
    108108
  • trunk/Source/WebKit/UIProcess/WebProcessPool.cpp

    r242302 r242303  
    15291529}
    15301530
    1531 bool WebProcessPool::usesNetworkingDaemon() const
    1532 {
    1533 #if PLATFORM(COCOA)
    1534     return m_configuration->usesNetworkingDaemon();
    1535 #else
    1536     return false;
    1537 #endif
    1538 }
    1539    
    15401531void WebProcessPool::setCacheModel(CacheModel cacheModel)
    15411532{
  • trunk/Source/WebKit/UIProcess/WebProcessPool.h

    r242124 r242303  
    269269    API::DownloadClient& downloadClient() { return *m_downloadClient; }
    270270
    271     bool usesNetworkingDaemon() const;
    272    
    273271    API::LegacyContextHistoryClient& historyClient() { return *m_historyClient; }
    274272    WebContextClient& client() { return m_client; }
Note: See TracChangeset for help on using the changeset viewer.