Bug 203960 - Port MessagePort to the HTML5 event loop
Summary: Port MessagePort to the HTML5 event loop
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL:
Keywords: InRadar
Depends on:
Blocks: 202843
  Show dependency treegraph
 
Reported: 2019-11-07 09:09 PST by Chris Dumez
Modified: 2019-11-08 08:10 PST (History)
11 users (show)

See Also:


Attachments
Patch (4.06 KB, patch)
2019-11-07 09:10 PST, Chris Dumez
rniwa: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2019-11-07 09:09:44 PST
Port MessagePort to the HTML5 event loop.
Comment 1 Chris Dumez 2019-11-07 09:10:25 PST
Created attachment 383055 [details]
Patch
Comment 2 Ryosuke Niwa 2019-11-07 14:04:22 PST
Comment on attachment 383055 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=383055&action=review

> Source/WebCore/dom/MessagePort.cpp:278
> -            m_eventQueue->enqueueEvent(MessageEvent::create(WTFMove(ports), message.message.releaseNonNull()));
> +            queueTaskToDispatchEvent(*this, TaskSource::PostedMessage, MessageEvent::create(WTFMove(ports), message.message.releaseNonNull()));

Hm... the posted message task source is only used for window post message steps:
https://html.spec.whatwg.org/multipage/web-messaging.html#window-post-message-steps
https://html.spec.whatwg.org/multipage/web-messaging.html#posted-message-task-source

Shouldn't this be port message queue or unshipped port message queue?
https://html.spec.whatwg.org/multipage/web-messaging.html#port-message-queue
Comment 3 Chris Dumez 2019-11-07 14:07:06 PST
Comment on attachment 383055 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=383055&action=review

>> Source/WebCore/dom/MessagePort.cpp:278
>> +            queueTaskToDispatchEvent(*this, TaskSource::PostedMessage, MessageEvent::create(WTFMove(ports), message.message.releaseNonNull()));
> 
> Hm... the posted message task source is only used for window post message steps:
> https://html.spec.whatwg.org/multipage/web-messaging.html#window-post-message-steps
> https://html.spec.whatwg.org/multipage/web-messaging.html#posted-message-task-source
> 
> Shouldn't this be port message queue or unshipped port message queue?
> https://html.spec.whatwg.org/multipage/web-messaging.html#port-message-queue

Looks like you're right, the spec says:
"Add a task that runs the following steps to the port message queue of targetPort:"

How do you propose I match the spec though?
Comment 4 Ryosuke Niwa 2019-11-07 14:09:15 PST
(In reply to Chris Dumez from comment #3)
> Comment on attachment 383055 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=383055&action=review
> 
> >> Source/WebCore/dom/MessagePort.cpp:278
> >> +            queueTaskToDispatchEvent(*this, TaskSource::PostedMessage, MessageEvent::create(WTFMove(ports), message.message.releaseNonNull()));
> > 
> > Hm... the posted message task source is only used for window post message steps:
> > https://html.spec.whatwg.org/multipage/web-messaging.html#window-post-message-steps
> > https://html.spec.whatwg.org/multipage/web-messaging.html#posted-message-task-source
> > 
> > Shouldn't this be port message queue or unshipped port message queue?
> > https://html.spec.whatwg.org/multipage/web-messaging.html#port-message-queue
> 
> Looks like you're right, the spec says:
> "Add a task that runs the following steps to the port message queue of
> targetPort:"
> 
> How do you propose I match the spec though?

I think we just add TaskSource type of PostMessageQueue. Maybe add a comment saying that the spec says each port has its own task source but we coalesce into one. Because HTML5 event loop spec allows whatever task source to be picked, this is okay for our implementation.
Comment 5 Chris Dumez 2019-11-07 15:16:13 PST
Committed r252209: <https://trac.webkit.org/changeset/252209>
Comment 6 Radar WebKit Bug Importer 2019-11-07 15:17:19 PST
<rdar://problem/57000643>
Comment 7 Aakash Jain 2019-11-08 07:07:24 PST
(In reply to Chris Dumez from comment #5)
> Committed r252209: <https://trac.webkit.org/changeset/252209>
This likely caused layout Test fast/workers/worker-close-more.html to fail. Tracked in https://bugs.webkit.org/show_bug.cgi?id=203995
Comment 8 Truitt Savell 2019-11-08 08:10:20 PST
(In reply to Aakash Jain from comment #7)
> (In reply to Chris Dumez from comment #5)
> > Committed r252209: <https://trac.webkit.org/changeset/252209>
> This likely caused layout Test fast/workers/worker-close-more.html to fail.
> Tracked in https://bugs.webkit.org/show_bug.cgi?id=203995

I was able to reproduce this by just running the test. It fails on 252209 but not on 252208