New issue
Advanced search Search tips

Issue 879510 link

Starred by 3 users

Issue metadata

Status: Duplicate
Merged: issue 874302
Owner: ----
Closed: Sep 4
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 3
Type: Bug



Sign in to add a comment

BroadcastChannel does not post SharedArrayBuffers

Project Member Reported by aerotwist@chromium.org, Aug 31

Issue description

I have a bit of code which should broadcast out a SharedArrayBuffer:

const buff = new SharedArrayBuffer(1);
let arr = new Uint8Array(buff);
arr[0] = 100;

const bOut = new BroadcastChannel("foo");
const bIn = new BroadcastChannel("foo");

bOut.onmessage = (evt) => {
  console.log(evt.data); // null, should be arr
};

bIn.postMessage(arr);

I expected the onmessage callback to get the Uint8Array as part of the payload of the event, as it does with ArrayBuffer or when using a MessageChannel. But evt.data is null, which I think is a bug. Is there any reason this shouldn't work?

 
Components: Blink>JavaScript
BroadcastChannel is somewhat incompatible with SharedArrayBuffer.  SharedArrayBuffer can only be accessed within a given agent cluster (aka stuff guaranteed to be in the same process):

https://html.spec.whatwg.org/#integration-with-the-javascript-agent-cluster-formalism

By design, though, BroadcastChannel crosses agent clusters (processes).
There is an open spec question about it:

https://github.com/whatwg/html/issues/3759
Cc: binji@chromium.org
I don't think the spec question is open, and I'll close that issue to make that more clear.

There is no incompatibility here, and the spec and tests are quite rigorous. There's a check when deserializing the transferred data that you're still in the same agent cluster, and if you're not, you get a messageerror event instead of a message event. (Of course, in implementations, presumably it would never cross the process boundary in the first place.) This was all worked out and agreed upon a long while ago.

CCing binji@ who is working on the implementation; maybe this is a dupe of one of their bugs.
Labels: Needs-Milestone
Mergedinto: 874302
Status: Duplicate (was: Unconfirmed)
Yes, this is currently not implemented. There is a bug to do so here: https://crbug.com/874302

Sign in to add a comment