Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 3e80e65d4fd85e1dbce0584210c99c0807063491
https://github.com/WebKit/WebKit/commit/3e80e65d4fd85e1dbce0584210c99c0807063491
Author: Franco Vieira de Souza <[email protected]>
Date: 2026-07-07 (Tue, 07 Jul 2026)
Changed paths:
A LayoutTests/fast/events/message-port-close-after-transfer-expected.txt
A LayoutTests/fast/events/message-port-close-after-transfer.html
M Source/WebCore/Modules/webaudio/AudioWorkletNode.cpp
M Source/WebCore/dom/MessagePort.cpp
M Source/WebCore/dom/MessagePort.h
M Source/WebCore/dom/ScriptExecutionContext.cpp
M Source/WebCore/workers/shared/SharedWorker.cpp
Log Message:
-----------
Closing an already-transferred MessagePort shouldn't break channel
https://bugs.webkit.org/show_bug.cgi?id=315394
rdar://177749843
Reviewed by Brady Eidson.
MessagePort::close() was improperly guarded if
MessagePort::disentangle() happened before it, causing it to tear down
a channel it no longer owns.
To fix this, MessagePort::State was introduced to replace the valid
combinations of (m_started, m_isDetached, m_entangled). There are now
only three states:
- NotStartedYet : entangled, waiting for start() to begin handling
received messages
- Started : entangled and start()'d
- Disentangled : not entangled, port was closed or shipped away
There is no longer a distinction between "disentangled" and
"detached" - both were collapsed into State::Disentangled. This matches
our implementation: we disentangle shipped ports eagerly on
postMessage() rather than deferring it to the receiver side, so
a "detached but not yet disentangled" intermediate state is not
possible.
lenientDisentangle() was introduced for code that leans on the
"detached but not disentangled" state - it skips the assert on
disentangle() so that it may succeed even if the port has already been
closed. This edge case happens when SharedWorker::create() or
AudioWorkletNode::create() run on a closed context.
Test: fast/events/message-port-close-after-transfer.html
Canonical link: https://commits.webkit.org/316652@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications