Hacker News new | ask | show | jobs
by panic 500 days ago
I don’t believe it is currently possible for a WebAssembly instance to access any buffer other than its own memory. You have to copy data in and out.
2 comments

The embedder could hand the module functions for manipulating external buffers via externrefs. (I'm not sure if that's a good idea, or not, just that it could.)

But if the module wants to compute on the values in the buffer, at some level it would have to copy the data in/out.

Use the GC instructions and you can freely share heap references amongst other modules and the host.
How do you access the contents of a heap reference from JavaScript in order to “send it to a <canvas> or similar”?
Assuming you're talking about reading binary data like (array i8), the GC MVP doesn't have a great answer right now. Have to call back into wasm to read the bytes. Something for the group to address in future proposals. Sharing between wasm modules is better right now.