Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 28f59c40aa4913fbacc1900cb2eb5e0ba55ef7f2
https://github.com/WebKit/WebKit/commit/28f59c40aa4913fbacc1900cb2eb5e0ba55ef7f2
Author: Chris Dumez <[email protected]>
Date: 2026-07-22 (Wed, 22 Jul 2026)
Changed paths:
M Source/WebKit/Shared/LogStream.mm
M Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm
M Source/WebKit/UIProcess/WebProcessProxy.cpp
M Source/WebKit/UIProcess/WebProcessProxy.h
Log Message:
-----------
LogStream leaks its IPC connection (and Mach port / kqueue workloop) after
the WebContent process exits
https://bugs.webkit.org/show_bug.cgi?id=319952
Reviewed by Per Arne Vollan.
When log forwarding is enabled, each WebContent process gets a LogStream in the
UI process
(WebProcessProxy::createLogStream), backed by a StreamServerConnection over its
own IPC::Connection.
LogStream::stopListeningForIPC() only called
StreamServerConnection::stopReceivingMessages(),
which unregisters the message receiver but never invalidates the underlying
IPC::Connection. An
open connection keeps itself alive through its Mach-receive dispatch source
(which holds a Ref
back to the connection) and holds its Mach port / kqueue workloop until it is
explicitly
invalidated. So tearing down the WebProcessProxy released its reference to the
LogStream but did
not release the connection: StreamServerConnection::m_receivers and the
connection's own receive
source kept the LogStream / StreamServerConnection / IPC::Connection alive as a
self-sustaining
island with a dead peer.
One such connection leaked per WebContent process. Over a long session these
accumulate in the UI
process until it is killed for Mach port exhaustion (32768) or kqueue workloop
exhaustion (2048),
whichever limit is reached first.
Fix LogStream::stopListeningForIPC() to also invalidate() the connection:
stopReceivingMessages()
clears the receiver map (breaking the m_receivers <-> m_connection retain cycle
so the objects can
be freed) and invalidate() cancels the receive source and releases the Mach
port / kqueue workloop.
Also tear the log stream down from WebProcessProxy::shutDown() (via a new
stopLogStream() helper,
shared with platformDestroy()) so the connection is released as soon as the
process shuts down,
rather than waiting for the proxy object to be destroyed.
* Source/WebKit/Shared/LogStream.mm:
(WebKit::LogStream::stopListeningForIPC):
* Source/WebKit/UIProcess/Cocoa/WebProcessProxyCocoa.mm:
(WebKit::WebProcessProxy::platformDestroy):
(WebKit::WebProcessProxy::stopLogStream):
* Source/WebKit/UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::shutDown):
* Source/WebKit/UIProcess/WebProcessProxy.h:
Canonical link: https://commits.webkit.org/317709@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications