Zero-copy pass ArrayBuffer from JS-land to WebAssembly-land
Hey, From reading about the WebAssembly.Memory there really is no way to pass an ArrayBuffer zero-copy to C++ from JS. Example: Let's say a WebSocket in the browser triggers the onmessage with an ArrayBuffer of the message data. Now I want to read this data in C++. From all solutions I've seen you really need to: 1. allocate a new WebAssembly.Memory (or whatever allocation strategy you use) 2. copy the contents of ArrayBuffer with the message to the ArrayBuffer of the WebAssembly.Memory 3. call into C++ and use the copied memory as char * 4. free the WebAssembly.Memory Imagine having a constructor like new WebAssembly.Memory(ArrayBuffer) so that you could skip all steps except for step 3. Did I get something wrong or is this not supported?
Posted by ghost on Dec 5, 2017, 7:59 PM
Tags
Related issues
- struct's lifetime requirements can be bypassed via covariant field assignment
- Proposal to Reorganize the Moderation Team and Review Moderation Policies
- Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
- proposal: container/...: generic collection types
- Better Custom Endpoint BYOK
- A concrete policy for backward compatibility until Godot 5.0
Raise real-world problems, find people facing the same issue, and discuss solutions.4,500 issues0 comments
github (Other)
struct's lifetime requirements can be bypassed via covariant field assignment
Proposal to Reorganize the Moderation Team and Review Moderation Policies
Progressive FPS degradation appears to be related to dota2.com — blocking the domain prevents the performance loss
proposal: container/...: generic collection types
Better Custom Endpoint BYOK
A concrete policy for backward compatibility until Godot 5.0
New MTP models not supported
Tracking: 429 / Capacity Issues
Zero-copy pass ArrayBuffer from JS-land to WebAssembly-land
Hey, From reading about the WebAssembly.Memory there really is no way to pass an ArrayBuffer zero-copy to C++ from JS. Example: Let's say a WebSocket in the browser triggers the onmessage with an ArrayBuffer of the message data. Now I want to read this data in C++. From all solutions I've seen you really need to: 1. allocate a new WebAssembly.Memory (or whatever allocation strategy you use) 2. copy the contents of ArrayBuffer with the message to the ArrayBuffer of the WebAssembly.Memory 3. call into C++ and use the copied memory as char * 4. free the WebAssembly.Memory Imagine having a constructor like new WebAssembly.Memory(ArrayBuffer) so that you could skip all steps except for step 3. Did I get something wrong or is this not supported?
Comments (0)
No comments yet. Start the discussion.