Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 900818e2cde3c693a0bfa07a2732cd6ccbd21647
https://github.com/WebKit/WebKit/commit/900818e2cde3c693a0bfa07a2732cd6ccbd21647
Author: Brady Eidson <[email protected]>
Date: 2026-08-12 (Wed, 12 Aug 2026)
Changed paths:
M Source/WebCore/dom/messageports/MessagePortChannel.cpp
M Source/WebCore/dom/messageports/MessagePortChannel.h
M Source/WebCore/dom/messageports/MessagePortChannelProviderImpl.cpp
M Source/WebCore/dom/messageports/MessagePortChannelRegistry.cpp
M Source/WebCore/dom/messageports/MessagePortChannelRegistry.h
M Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp
M Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h
M
Source/WebKit/NetworkProcess/SharedWorker/WebSharedWorkerServerConnection.cpp
M Tools/TestWebKitAPI/Resources/cocoa/MessagePortSecurity.mm
Log Message:
-----------
MessagePorts + SharedWorkers have a bad time with recently added message
checks
rdar://184338230
https://bugs.webkit.org/show_bug.cgi?id=321471
Reviewed by Chris Dumez.
If a SharedWorker's web content process dies while one of its clients is in the
back/forward cache,
it is relaunched for the sake of that client. Any message ports are then
re-entangled.
The networking process only releases message port ownership in
~NetworkConnectionToWebProcess, which
can run long after ::didClose() starts the relaunch. This causes the
re-entanglement for ports "owned"
by the dead process to be message checked against the new process.
We can release port ownership in didClose() instead, and treat a port owned by
a process with no live
connection as "unreleased" instead of a misbehaving sender.
MessagePortChannel::closePort() also latched m_isClosed with nothing to clear
it, so once the worker
relaunches every message the client sent it was silently dropped;
entanglePortWithProcess() now clears it.
New test:
MessagePortSecurity.SharedWorkerPortStillWorksAfterContextProcessDiesWithCachedClient
* Source/WebCore/dom/messageports/MessagePortChannel.cpp:
(WebCore::MessagePortChannel::entanglePortWithProcess):
(WebCore::MessagePortChannel::disentanglePort):
(WebCore::MessagePortChannel::closePort):
(WebCore::MessagePortChannel::postMessageToRemote):
* Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::~NetworkConnectionToWebProcess):
(WebKit::NetworkConnectionToWebProcess::closeAllEntangledMessagePorts):
(WebKit::NetworkConnectionToWebProcess::didClose):
(WebKit::NetworkConnectionToWebProcess::entangleLocalPortInThisProcessToRemote):
(WebKit::NetworkConnectionToWebProcess::takeAllMessagesForPort):
(WebKit::NetworkConnectionToWebProcess::messagePortClosed):
* Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.h:
* Tools/TestWebKitAPI/Resources/cocoa/MessagePortSecurity.mm:
((MessagePortSecurity,
SharedWorkerPortStillWorksAfterContextProcessDiesWithCachedClient)):
* Source/WebCore/dom/messageports/MessagePortChannel.h:
* Source/WebCore/dom/messageports/MessagePortChannelProviderImpl.cpp:
(WebCore::MessagePortChannelProviderImpl::messagePortClosed):
* Source/WebCore/dom/messageports/MessagePortChannelRegistry.cpp:
(WebCore::MessagePortChannelRegistry::didCloseMessagePort):
* Source/WebCore/dom/messageports/MessagePortChannelRegistry.h:
Canonical link: https://commits.webkit.org/319041@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications