Issue metadata
Sign in to add a comment
|
BroadcastChannel does not post SharedArrayBuffers |
||||||||||||||||||||||||
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?
,
Aug 31
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).
,
Aug 31
There is an open spec question about it: https://github.com/whatwg/html/issues/3759
,
Aug 31
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.
,
Sep 2
,
Sep 4
Yes, this is currently not implemented. There is a bug to do so here: https://crbug.com/874302 |
|||||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||||
Comment 1 by aerotwist@chromium.org
, Aug 31