Bug 256278 - Running API tests often logs "Error while launching com.apple.WebKit.Networking: Connection invalid"
Summary: Running API tests often logs "Error while launching com.apple.WebKit.Networki...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-05-03 16:00 PDT by Simon Fraser (smfr)
Modified: 2023-05-04 16:38 PDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Fraser (smfr) 2023-05-03 16:00:46 PDT
Running an API test on macOS (I was launching TestWebKitAPI with `--gtest_filter=TextManipulation.CompleteTextManipulationAddsOverflowHiddenToAvoidBreakingLayout`) often shows:

ERROR: Error while launching com.apple.WebKit.Networking: Connection invalid
/Volumes/Data/Development/system/webkit/OpenSource/Source/WebKit/UIProcess/Launcher/cocoa/ProcessLauncherCocoa.mm(229) : auto WebKit::ProcessLauncher::launchProcess()::(anonymous class)::operator()(xpc_object_t) const

Some logging shows:

ProcessLauncher 0x117059e90 launch process com.apple.WebKit.WebContent
WebProcessProxy 0x143000c00 didFinishLaunching - launcher 0x117059e90
NetworkProcessProxy ctor 0x1170ac110
ProcessLauncher 0x1170b4130 launch process com.apple.WebKit.Networking
NetworkProcessProxy ctor 0x1170ac110 connected
NetworkProcessProxy dtor 0x1170ac110
ProcessLauncher 0x1170b4130 terminateXPCConnection
ProcessLauncher - launch process got error

So we make a NetworkProcessProxy and immediately destroy it. This happens when we lose the last ref to the NetworkProcessProxy here:

  * frame #0: 0x000000012d6ff764 WebKit`WebKit::NetworkProcessProxy::~NetworkProcessProxy(this=0x000000010802c460) at NetworkProcessProxy.cpp:272:5
    frame #1: 0x000000012d6ffb9c WebKit`WebKit::NetworkProcessProxy::~NetworkProcessProxy(this=0x000000010802c460) at NetworkProcessProxy.cpp:271:1
    frame #2: 0x000000012d6ffc20 WebKit`WebKit::NetworkProcessProxy::~NetworkProcessProxy(this=0x000000010802c460) at NetworkProcessProxy.cpp:271:1
    frame #3: 0x000000012e574878 WebKit`WTF::ThreadSafeRefCounted<WebKit::AuxiliaryProcessProxy, (WTF::DestructionThread)2>::deref(this=0x0000000108004c98) const::'lambda'()::operator()() const at ThreadSafeRefCounted.h:115:13
    frame #4: 0x000000012bd60eb0 WebKit`WTF::Detail::CallableWrapper<WTF::ThreadSafeRefCounted<WebKit::AuxiliaryProcessProxy, (WTF::DestructionThread)2>::deref() const::'lambda'(), void>::call(this=0x0000000108004c90) at Function.h:53:39
    frame #5: 0x000000010d4fb3c8 JavaScriptCore`WTF::Function<void ()>::operator()(this=0x000000016fdfd508) const at Function.h:82:35
    frame #6: 0x000000010d559fd0 JavaScriptCore`WTF::ensureOnMainRunLoop(function=0x000000016fdfd508) at MainThread.cpp:74:9
    frame #7: 0x000000012bd60d64 WebKit`WTF::ThreadSafeRefCounted<WebKit::AuxiliaryProcessProxy, (WTF::DestructionThread)2>::deref(this=0x000000010802c468) const at ThreadSafeRefCounted.h:124:13
    frame #8: 0x000000012bd60ce0 WebKit`WebKit::AuxiliaryProcessProxy::deref(this=0x000000010802c460) at AuxiliaryProcessProxy.h:159:48
    frame #9: 0x000000012bd60c7c WebKit`WTF::Ref<WebKit::NetworkProcessProxy, WTF::RawPtrTraits<WebKit::NetworkProcessProxy>>::~Ref(this=0x000000016fdfd5c0) at Ref.h:61:18
    frame #10: 0x000000012bd5a948 WebKit`WTF::Ref<WebKit::NetworkProcessProxy, WTF::RawPtrTraits<WebKit::NetworkProcessProxy>>::~Ref(this=0x000000016fdfd5c0) at Ref.h:55:5
    frame #11: 0x000000012d5b96b0 WebKit`WebKit::WebProcessProxy::didFinishLaunching(WebKit::ProcessLauncher*, IPC::Connection::Identifier)::$_57::operator()(this=0x0000000108001da8) const at WebProcessProxy.cpp:1208:13
    frame #12: 0x000000012d5b95ac WebKit`WTF::Detail::CallableWrapper<WebKit::WebProcessProxy::didFinishLaunching(WebKit::ProcessLauncher*, IPC::Connection::Identifier)::$_57, void>::call(this=0x0000000108001da0) at Function.h:53:39
    frame #13: 0x000000010d4fb3c8 JavaScriptCore`WTF::Function<void ()>::operator()(this=0x000000016fdfd660) const at Function.h:82:35
    frame #14: 0x000000010d5968d8 JavaScriptCore`WTF::RunLoop::performWork(this=0x0000000108010100) at RunLoop.cpp:147:9
    frame #15: 0x000000010d59ada4 JavaScriptCore`WTF::RunLoop::performWork(context=0x0000000108010100) at RunLoopCF.cpp:46:37
    frame #16: 0x0000000183f474c8 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
    frame #17: 0x0000000183f4745c CoreFoundation`__CFRunLoopDoSource0 + 176
    frame #18: 0x0000000183f471cc CoreFoundation`__CFRunLoopDoSources0 + 244
    frame #19: 0x0000000183f45dd4 CoreFoundation`__CFRunLoopRun + 828
    frame #20: 0x0000000183f453e4 CoreFoundation`CFRunLoopRunSpecific + 600
    frame #21: 0x0000000184fb0cf8 Foundation`-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 212
    frame #22: 0x0000000100e69554 TestWebKitAPI`TestWebKitAPI::Util::run(done=0x00006000034c9278) at UtilitiesCocoa.mm:35:9
    frame #23: 0x0000000100e51d20 TestWebKitAPI`-[TestNavigationDelegate waitForDidFinishNavigation](self=0x0000600001feb790, _cmd="waitForDidFinishNavigation") at TestNavigationDelegate.mm:140:5
    frame #24: 0x0000000100e53584 TestWebKitAPI`-[WKWebView(self=0x000000014aeb6d90, _cmd="_test_waitForDidFinishNavigation") _test_waitForDidFinishNavigation] at TestNavigationDelegate.mm:248:5
    frame #25: 0x0000000100e565e4 TestWebKitAPI`-[WKWebView(self=0x000000014aeb6d90, _cmd="synchronouslyLoadHTMLString:baseURL:", html="<!DOCTYPE html><html><head>  <style>    span {      display: inline-block;      width: 28px;      height: 40px;      margin: 0;      word-break: break-all;      font-size: 32px;    }    a {      display: block;      width: 100px;      height: 100px;      overflow: hidden;    }  </style></head><body>  <a>    <span>A</span> Hello world  </a></body></html>", url="file:///Volumes/Data/Development/system/webkit/OpenSource/WebKitBuild/Debug/TestWebKitAPI.resources/") synchronouslyLoadHTMLString:baseURL:] at TestWKWebView.mm:105:5
    frame #26: 0x0000000100e56658 TestWebKitAPI`-[WKWebView(self=0x000000014aeb6d90, _cmd="synchronouslyLoadHTMLString:", html="<!DOCTYPE html><html><head>  <style>    span {      display: inline-block;      width: 28px;      height: 40px;      margin: 0;      word-break: break-all;      font-size: 32px;    }    a {      display: block;      width: 100px;      height: 100px;      overflow: hidden;    }  </style></head><body>  <a>    <span>A</span> Hello world  </a></body></html>") synchronouslyLoadHTMLString:] at TestWKWebView.mm:110:5
    frame #27: 0x0000000100b373e4 TestWebKitAPI`TestWebKitAPI::TextManipulation_CompleteTextManipulationAddsOverflowHiddenToAvoidBreakingLayout_Test::TestBody(this=0x00006000036be570) at TextManipulation.mm:3420:5
    frame #28: 0x0000000100f4b6bc TestWebKitAPI`void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(object=0x00006000036be570, method=(actual=0x0000000100eff530 TestWebKitAPI`_ZN7testing4Test8TestBodyEv_vfpthunk_ at gtest.cc:2707:3), location="the test body") at gtest.cc:2607:10
    frame #29: 0x0000000100eff25c TestWebKitAPI`void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(object=0x00006000036be570, method=(actual=0x0000000100eff530 TestWebKitAPI`_ZN7testing4Test8TestBodyEv_vfpthunk_ at gtest.cc:2707:3), location="the test body") at gtest.cc:2643:14
    frame #30: 0x0000000100eff190 TestWebKitAPI`testing::Test::Run(this=0x00006000036be570) at gtest.cc:2682:5
    frame #31: 0x0000000100f003e8 TestWebKitAPI`testing::TestInfo::Run(this=0x000000014ae74320) at gtest.cc:2861:11
    frame #32: 0x0000000100f017c0 TestWebKitAPI`testing::TestSuite::Run(this=0x000000014ae6e8e0) at gtest.cc:3015:28
    frame #33: 0x0000000100f0fd04 TestWebKitAPI`testing::internal::UnitTestImpl::RunAllTests(this=0x000000014ae04980) at gtest.cc:5851:44
    frame #34: 0x0000000100f4c098 TestWebKitAPI`bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(object=0x000000014ae04980, method=(actual=0x0000000100f0f858 TestWebKitAPI`testing::internal::UnitTestImpl::RunAllTests() at gtest.cc:5742), location="auxiliary test code (environments or event listeners)") at gtest.cc:2607:10
    frame #35: 0x0000000100f0f5cc TestWebKitAPI`bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(object=0x000000014ae04980, method=(actual=0x0000000100f0f858 TestWebKitAPI`testing::internal::UnitTestImpl::RunAllTests() at gtest.cc:5742), location="auxiliary test code (environments or event listeners)") at gtest.cc:2643:14
    frame #36: 0x0000000100f0f4b0 TestWebKitAPI`testing::UnitTest::Run(this=0x00000001012b5a80) at gtest.cc:5434:10
    frame #37: 0x0000000100571e58 TestWebKitAPI`RUN_ALL_TESTS() at gtest.h:2471:46
    frame #38: 0x0000000100571de4 TestWebKitAPI`TestWebKitAPI::TestsController::run(this=0x00000001012b5268, argc=1, argv=0x000000016fdff590) at TestsController.cpp:89:13
    frame #39: 0x0000000100ed2418 TestWebKitAPI`main(argc=2, argv=0x000000016fdff590) at mainMac.mm:83:62


So no-one retains the NetworkProcessProxy created at:
            NetworkProcessProxy::ensureDefaultNetworkProcess()->sendXPCEndpointToProcess(*weakThis);
Comment 1 Radar WebKit Bug Importer 2023-05-03 16:23:11 PDT
<rdar://problem/108866781>
Comment 2 Chris Dumez 2023-05-03 16:27:45 PDT
Pull request: https://github.com/WebKit/WebKit/pull/13423
Comment 3 EWS 2023-05-04 16:38:01 PDT
Committed 263698@main (3d791e9725a5): <https://commits.webkit.org/263698@main>

Reviewed commits have been landed. Closing PR #13423 and removing active labels.