[webkit-changes] [WebKit/WebKit] a4790b: MessagePort is unexpectedly GC'ed after activity a...
Chris Dumez
noreply at github.com
Fri Nov 4 15:49:35 PDT 2022
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: a4790ba92ba790c7c332319b48b972b51053b765
https://github.com/WebKit/WebKit/commit/a4790ba92ba790c7c332319b48b972b51053b765
Author: Chris Dumez <cdumez at apple.com>
Date: 2022-11-04 (Fri, 04 Nov 2022)
Changed paths:
A LayoutTests/fast/events/message-port-gc-after-closing-expected.txt
A LayoutTests/fast/events/message-port-gc-after-closing.html
A LayoutTests/fast/events/message-port-gc-after-removing-event-listener-expected.txt
A LayoutTests/fast/events/message-port-gc-after-removing-event-listener.html
A LayoutTests/fast/events/resources/message-port-gc-worker.js
A LayoutTests/http/tests/messaging/messageport-gc-after-xhr-expected.txt
A LayoutTests/http/tests/messaging/messageport-gc-after-xhr.html
A LayoutTests/http/tests/messaging/resources/messageport-pong-after-xhr.html
M Source/WebCore/dom/MessagePort.cpp
M Source/WebCore/dom/MessagePort.h
M Source/WebCore/dom/MessagePort.idl
M Source/WebCore/testing/Internals.cpp
M Source/WebCore/testing/Internals.h
M Source/WebCore/testing/Internals.idl
Log Message:
-----------
MessagePort is unexpectedly GC'ed after activity absence
https://bugs.webkit.org/show_bug.cgi?id=193184
rdar://54095480
Reviewed by Ryosuke Niwa and Geoffrey Garen.
Per the HTML specification [1], we should keep the MessagePort alive as long
as it is entangled. This makes sense since the port could receive messages as
long as it is entangled. However, we were missing this check inside
MessagePort::virtualHasPendingActivity().
We do still allow collection when entangled if there is no message event handler,
since it wouldn't be observable then. Even if a new message would arrive, there
would be no-one on JS side to notify.
[1] https://html.spec.whatwg.org/multipage/web-messaging.html#ports-and-garbage-collection
* LayoutTests/http/tests/messaging/messageport-gc-after-xhr-expected.txt: Added.
* LayoutTests/http/tests/messaging/messageport-gc-after-xhr.html: Added.
* LayoutTests/http/tests/messaging/resources/messageport-pong-after-xhr.html: Added.
Add test coverage. The test is based on the one provided by Yoshiaki Jitsukawa from
Sony.
* Source/WebCore/dom/MessagePort.cpp:
(WebCore::MessagePort::virtualHasPendingActivity const):
Canonical link: https://commits.webkit.org/256342@main
More information about the webkit-changes
mailing list