[macOS] The network process is not exiting reliably when the WebProcessPool is destroyed
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Mar 2019 23:54:11 +0000 (23:54 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Mar 2019 23:54:11 +0000 (23:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196277
<rdar://problem/49127581>

Reviewed by Alex Christensen.

When, an AuxiliaryProcess receives the AuxiliaryProcess::Terminate IPC, it calls stopRunLoop()
to exit. WebProcess overrides AuxiliaryProcess::stopRunLoop() to call exit(0) on the main
thread. Other auxiliary processes such as the NetworkProcess would end up calling
platformStopRunLoop(). On iOS and iOSMac, platformStopRunLoop() calls XPCServiceExit(), which
makes sense since auxiliary processes run their run loop by calling xpc_main(). However, on
macOS, platformStopRunLoop() was calling RunLoop::main().stop() to exit instead, which was
unreliable as demonstrated by the test app attached to the radar.

Updating platformStopRunLoop() to call XPCServiceExit() on macOS fixes the problem and I now
see the NetworkProcess exiting reliably there. This is the approach I have chosen in this
patch since it appears to be reliable and it makes the code consistent on all Cocoa platforms.

* Shared/AuxiliaryProcess.cpp:
* Shared/Cocoa/AuxiliaryProcessCocoa.mm:
(WebKit::AuxiliaryProcess::platformStopRunLoop):
* Shared/ios/AuxiliaryProcessIOS.mm:
(WebKit::AuxiliaryProcess::platformStopRunLoop): Deleted.
* Shared/mac/AuxiliaryProcessMac.mm:
(WebKit::AuxiliaryProcess::platformStopRunLoop): Deleted.

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

Source/WebKit/ChangeLog
Source/WebKit/Shared/AuxiliaryProcess.cpp
Source/WebKit/Shared/Cocoa/AuxiliaryProcessCocoa.mm
Source/WebKit/Shared/ios/AuxiliaryProcessIOS.mm
Source/WebKit/Shared/mac/AuxiliaryProcessMac.mm

index 743b2ff..928202b 100644 (file)
@@ -1,3 +1,31 @@
+2019-03-26  Chris Dumez  <cdumez@apple.com>
+
+        [macOS] The network process is not exiting reliably when the WebProcessPool is destroyed
+        https://bugs.webkit.org/show_bug.cgi?id=196277
+        <rdar://problem/49127581>
+
+        Reviewed by Alex Christensen.
+
+        When, an AuxiliaryProcess receives the AuxiliaryProcess::Terminate IPC, it calls stopRunLoop()
+        to exit. WebProcess overrides AuxiliaryProcess::stopRunLoop() to call exit(0) on the main
+        thread. Other auxiliary processes such as the NetworkProcess would end up calling
+        platformStopRunLoop(). On iOS and iOSMac, platformStopRunLoop() calls XPCServiceExit(), which
+        makes sense since auxiliary processes run their run loop by calling xpc_main(). However, on
+        macOS, platformStopRunLoop() was calling RunLoop::main().stop() to exit instead, which was
+        unreliable as demonstrated by the test app attached to the radar.
+
+        Updating platformStopRunLoop() to call XPCServiceExit() on macOS fixes the problem and I now
+        see the NetworkProcess exiting reliably there. This is the approach I have chosen in this
+        patch since it appears to be reliable and it makes the code consistent on all Cocoa platforms.
+
+        * Shared/AuxiliaryProcess.cpp:
+        * Shared/Cocoa/AuxiliaryProcessCocoa.mm:
+        (WebKit::AuxiliaryProcess::platformStopRunLoop):
+        * Shared/ios/AuxiliaryProcessIOS.mm:
+        (WebKit::AuxiliaryProcess::platformStopRunLoop): Deleted.
+        * Shared/mac/AuxiliaryProcessMac.mm:
+        (WebKit::AuxiliaryProcess::platformStopRunLoop): Deleted.
+
 2019-03-26  Keith Rollin  <krollin@apple.com>
 
         Inhibit CFNetwork logging in private sessions
index abb0f4d..067f708 100644 (file)
@@ -174,7 +174,7 @@ void AuxiliaryProcess::stopRunLoop()
     platformStopRunLoop();
 }
 
-#if !PLATFORM(IOS_FAMILY)
+#if !PLATFORM(COCOA)
 void AuxiliaryProcess::platformStopRunLoop()
 {
     RunLoop::main().stop();
index e2d9eee..0a1a7a2 100644 (file)
@@ -27,6 +27,7 @@
 #import "AuxiliaryProcess.h"
 
 #import "WKCrashReporter.h"
+#import "XPCServiceEntryPoint.h"
 #import <wtf/cocoa/Entitlements.h>
 
 namespace WebKit {
@@ -42,4 +43,9 @@ bool AuxiliaryProcess::parentProcessHasEntitlement(const char* entitlement)
     return WTF::hasEntitlement(m_connection->xpcConnection(), entitlement);
 }
 
+void AuxiliaryProcess::platformStopRunLoop()
+{
+    XPCServiceExit(WTFMove(m_priorityBoostMessage));
+}
+
 }
index 1759b27..e5e946f 100644 (file)
@@ -113,11 +113,6 @@ void AuxiliaryProcess::setQOS(int, int)
 
 }
 
-void AuxiliaryProcess::platformStopRunLoop()
-{
-    XPCServiceExit(WTFMove(m_priorityBoostMessage));
-}
-
 } // namespace WebKit
 
 #endif
index 5d3ae88..b157fcb 100644 (file)
@@ -695,13 +695,6 @@ void AuxiliaryProcess::stopNSRunLoop()
 }
 #endif
 
-#if PLATFORM(IOSMAC)
-void AuxiliaryProcess::platformStopRunLoop()
-{
-    XPCServiceExit(WTFMove(m_priorityBoostMessage));
-}
-#endif
-
 void AuxiliaryProcess::setQOS(int latencyQOS, int throughputQOS)
 {
     if (!latencyQOS && !throughputQOS)