Re: [whatwg/streams] Why does the `read` method of `ReadableStreamBYOBReader` class, need to _transfer_ the buffer it is provided? (Issue #1348)

eqrion left a comment (whatwg/streams#1348)

@amn Which specification that forbids what?

There's not a great single place to link in the wasm spec (which I'm most familiar with) to describe the 'memory model' of unshared memory, it's implied by all the permitted mutations scattered across the spec. But basically, a wasm unshared memory can only be mutated by wasm instructions while a wasm function is running (e.g. single threaded). When a wasm function calls into a host function (like JS or a browser API), an exported memory could be mutated arbitrarily. But only while the external function is running.

I linked to the part of the wasm spec that mandates a wasm memory cannot be detached [here](https://github.com/WebAssembly/spec/issues/1953#issuecomment-3133980511).

I think the right place to fix this issue would be to relax it so that SharedArrayBuffer's are allowed (basically #757). We did some initial prototyping of this in Firefox [here](https://bugzilla.mozilla.org/show_bug.cgi?id=1949223), but haven't landed the code behind a pref yet.

If you have a use case for this that could be used as a demo to demonstrate performance wins, that would be really helpful. We could get the change landed in Firefox (behind an experimental pref) and you could test it in a live browser.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/1348#issuecomment-3136973612
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/streams/issues/1348/3136973612@github.com>

Received on Wednesday, 30 July 2025 16:10:56 UTC