The WebProcess should use the NSRunLoop runloop type.
authorpvollan@apple.com <pvollan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Dec 2017 22:24:30 +0000 (22:24 +0000)
committerpvollan@apple.com <pvollan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Dec 2017 22:24:30 +0000 (22:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179804
<rdar://problem/14012823>

Reviewed by Brent Fulgham.

Source/WebCore:

No new tests.

* platform/mac/EventLoopMac.mm:
(WebCore::EventLoop::cycle):

Source/WebKit:

* Platform/IPC/mac/ConnectionMac.mm:
(IPC::AccessibilityProcessSuspendedNotification):
* Shared/ChildProcess.h:
* Shared/mac/ChildProcessMac.mm:
(WebKit::ChildProcess::launchServicesCheckIn):
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::shouldLeakBoost):
* WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-OSX.plist:
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeProcess):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225597 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/mac/EventLoopMac.mm
Source/WebKit/ChangeLog
Source/WebKit/Platform/IPC/mac/ConnectionMac.mm
Source/WebKit/Shared/ChildProcess.h
Source/WebKit/Shared/mac/ChildProcessMac.mm
Source/WebKit/UIProcess/Launcher/mac/ProcessLauncherMac.mm
Source/WebKit/WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-OSX.plist
Source/WebKit/WebProcess/WebProcess.cpp

index 396f1db..88ec3a4 100644 (file)
@@ -1,3 +1,16 @@
+2017-12-06  Per Arne Vollan  <pvollan@apple.com>
+
+        The WebProcess should use the NSRunLoop runloop type.
+        https://bugs.webkit.org/show_bug.cgi?id=179804
+        <rdar://problem/14012823>
+
+        Reviewed by Brent Fulgham.
+
+        No new tests.
+
+        * platform/mac/EventLoopMac.mm:
+        (WebCore::EventLoop::cycle):
+
 2017-12-06  Antti Koivisto  <antti@apple.com>
 
         Prefer ids and classes over tag names in selector filter
index 26ed582..8c98be2 100644 (file)
@@ -30,6 +30,10 @@ namespace WebCore {
 
 void EventLoop::cycle()
 {
+    if (![NSApp isRunning]) {
+        [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.05]];
+        return;
+    }
     [NSApp setWindowsNeedUpdate:YES];
     if (NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate dateWithTimeIntervalSinceNow:0.05] inMode:NSDefaultRunLoopMode dequeue:YES])
         [NSApp sendEvent:event];
index aabb795..e5dea24 100644 (file)
@@ -1,3 +1,22 @@
+2017-12-06  Per Arne Vollan  <pvollan@apple.com>
+
+        The WebProcess should use the NSRunLoop runloop type.
+        https://bugs.webkit.org/show_bug.cgi?id=179804
+        <rdar://problem/14012823>
+
+        Reviewed by Brent Fulgham.
+
+        * Platform/IPC/mac/ConnectionMac.mm:
+        (IPC::AccessibilityProcessSuspendedNotification):
+        * Shared/ChildProcess.h:
+        * Shared/mac/ChildProcessMac.mm:
+        (WebKit::ChildProcess::launchServicesCheckIn):
+        * UIProcess/Launcher/mac/ProcessLauncherMac.mm:
+        (WebKit::shouldLeakBoost):
+        * WebProcess/EntryPoint/mac/XPCService/WebContentService/Info-OSX.plist:
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::initializeProcess):
+
 2017-12-06  Nan Wang  <n_wang@apple.com>
 
         AX: [iOS] Post accessibility notification when a web process changes its suspended state
index fd32860..3d21e81 100644 (file)
@@ -586,6 +586,9 @@ bool Connection::kill()
 static void AccessibilityProcessSuspendedNotification(bool suspended)
 {
 #if PLATFORM(MAC)
+    // Calling _AXUIElementNotifyProcessSuspendStatus will crash if the NSApplication event loop is not running.
+    if (![NSApp isRunning])
+        return;
     _AXUIElementNotifyProcessSuspendStatus(suspended ? AXSuspendStatusSuspended : AXSuspendStatusRunning);
 #elif PLATFORM(IOS)
     UIAccessibilityPostNotification(kAXPidStatusChangedNotification, @{ @"pid" : @(getpid()), @"suspended" : @(suspended) });
index 2e30c1f..f1a32ec 100644 (file)
@@ -70,6 +70,7 @@ public:
 
 #if PLATFORM(COCOA)
     void setApplicationIsDaemon();
+    void launchServicesCheckIn();
     void setQOS(int latencyQOS, int throughputQOS);
 #endif
 
index 276e6e3..88949a3 100644 (file)
@@ -70,6 +70,11 @@ void ChildProcess::setApplicationIsDaemon()
     OSStatus error = SetApplicationIsDaemon(true);
     ASSERT_UNUSED(error, error == noErr);
 
+    launchServicesCheckIn();
+}
+
+void ChildProcess::launchServicesCheckIn()
+{
     _LSSetApplicationLaunchServicesServerConnectionStatus(0, 0);
     RetainPtr<CFDictionaryRef> unused = _LSApplicationCheckIn(-2, CFBundleGetInfoDictionary(CFBundleGetMainBundle()));
 }
index f19899b..d176bfc 100644 (file)
@@ -77,7 +77,8 @@ static bool shouldLeakBoost(const ProcessLauncher::LaunchOptions& launchOptions)
     return true;
 #else
     // On Mac, leak a boost onto the NetworkProcess.
-    return launchOptions.processType == ProcessLauncher::ProcessType::Network;
+    return launchOptions.processType == ProcessLauncher::ProcessType::Network
+        || launchOptions.processType == ProcessLauncher::ProcessType::Web;
 #endif
 }
 
index 3e5deb9..1f139fe 100644 (file)
@@ -45,7 +45,7 @@
                <key>ServiceType</key>
                <string>Application</string>
                <key>RunLoopType</key>
-               <string>_NSApplicationMain</string>
+               <string>NSRunLoop</string>
                <key>_MultipleInstances</key>
                <true/>
                <key>_HighBitsASLR</key>
index eed7002..356c02e 100644 (file)
@@ -216,6 +216,11 @@ WebProcess::~WebProcess()
 
 void WebProcess::initializeProcess(const ChildProcessInitializationParameters& parameters)
 {
+#if PLATFORM(COCOA) && !PLATFORM(IOS)
+    // This call is needed when the WebProcess is not running the NSApplication event loop.
+    // Otherwise, calling enableSandboxStyleFileQuarantine() will fail.
+    launchServicesCheckIn();
+#endif
     platformInitializeProcess(parameters);
 }