Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a4790ba92ba790c7c332319b48b972b51053b765
      
https://github.com/WebKit/WebKit/commit/a4790ba92ba790c7c332319b48b972b51053b765
  Author: Chris Dumez <[email protected]>
  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


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to