[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)
commit2e93ae592c37ce9fcb1e78df137b98ac8aea7864
treefdbbf55566a32dc6f922adb87a024801c926e7de
parent50585170e2c4312ac27b7dc49c4fdb8ebcefb329
[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.

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