Closed Bug 1605566 Opened 6 years ago Closed 6 years ago

MessagePort should support wasm modules and SharedArrayBuffer when possible

Categories

(Core :: DOM: postMessage, task)

task
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla74
Tracking Status
firefox74 --- fixed

People

(Reporter: baku, Assigned: baku)

References

Details

Attachments

(5 files, 7 obsolete files)

47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review
47 bytes, text/x-phabricator-request
Details | Review

We don't support the sending of WasmModules and SharedArrayBuffer via MessagePort because, in theory, ports work between processes. But this scenario is extremely rare and it requires the user sharedWorkers, which are not so common yet.

I want to suggest a different approach where we support the serialization of everything for normal scenarios and, on the remote occasion the messaging is cross-process, we dispatch a messageerror event.

This is compatible with the current spec definition.

Assignee: nobody → amarchesini
Status: NEW → ASSIGNED

Depends on D58080

Could you explain where messageerror gets dispatched?

By spec, messageerror is dispatched if the deserialization fails:

https://html.spec.whatwg.org/multipage/web-messaging.html#message-port-post-message-steps
7.3:

Let deserializeRecord be StructuredDeserializeWithTransfer(serializeWithTransferResult, targetRealm).
If this throws an exception, catch it, fire an event named messageerror at finalTargetPort, using MessageEvent, and then return.

In my code, this happens when the MessagePort receives a RefMessageBody ID from a different process.

Attachment #9117430 - Attachment is obsolete: true
Attachment #9117428 - Attachment is obsolete: true
Attachment #9117429 - Attachment is obsolete: true
Attachment #9117431 - Attachment is obsolete: true
Attachment #9117427 - Attachment is obsolete: true
Pushed by amarchesini@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/37026beadbd8 MessagePort + wasm - part 1 - access scope via method in StructuredClone code, r=sfink https://hg.mozilla.org/integration/autoland/rev/554b2bdce66c MessagePort + wasm - part 2 - implement JS::StructuredCloneScope::UnknownDestination, r=sfink https://hg.mozilla.org/integration/autoland/rev/36631ec96f1f MessagePort + wasm - part 3 - MessagePort serializes objects using MessageData union, r=smaug https://hg.mozilla.org/integration/autoland/rev/3427a92445c8 MessagePort + wasm - part 4 - Implement RefMessageBodyService, r=smaug https://hg.mozilla.org/integration/autoland/rev/39f34852842e MessagePort + wasm - part 5 - tests, r=smaug
Attachment #9121421 - Attachment is obsolete: true
Attachment #9121876 - Attachment is obsolete: true
Pushed by amarchesini@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/77bdf4f86052 MessagePort + wasm - part 1 - access scope via method in StructuredClone code, r=sfink https://hg.mozilla.org/integration/autoland/rev/99f61f25ed86 MessagePort + wasm - part 2 - implement JS::StructuredCloneScope::UnknownDestination, r=sfink https://hg.mozilla.org/integration/autoland/rev/7eab8fd2b62e MessagePort + wasm - part 3 - MessagePort serializes objects using MessageData union, r=smaug https://hg.mozilla.org/integration/autoland/rev/ab98304e6c84 MessagePort + wasm - part 4 - Implement RefMessageBodyService, r=smaug https://hg.mozilla.org/integration/autoland/rev/622939cef438 MessagePort + wasm - part 5 - tests, r=smaug
Flags: needinfo?(amarchesini)
Pushed by amarchesini@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d0f4082f969d MessagePort + wasm - part 1 - access scope via method in StructuredClone code, r=sfink https://hg.mozilla.org/integration/autoland/rev/9ccdf46d9dd4 MessagePort + wasm - part 2 - implement JS::StructuredCloneScope::UnknownDestination, r=sfink https://hg.mozilla.org/integration/autoland/rev/b55456d966a4 MessagePort + wasm - part 3 - MessagePort serializes objects using MessageData union, r=smaug https://hg.mozilla.org/integration/autoland/rev/be8a9e4029f6 MessagePort + wasm - part 4 - Implement RefMessageBodyService, r=smaug https://hg.mozilla.org/integration/autoland/rev/a7d7f6d229c8 MessagePort + wasm - part 5 - tests, r=smaug
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: