Should test for Uint8Array rather than ArrayBuffer?
Closed this issue · 4 comments
I can't get this to correctly call wam_onmessageA(), unless I modify this line to test if data is a Uint8Array.
I send the message like this on controller side...
EM_ASM({
var jsbuff = Module.HEAPU8.subarray($1, $1 + $2);
window[Module.Pointer_stringify($0)].sendMessage('SAMFUI', "", jsbuff);
}, "ControllerObjName", (int) pData, dataSize);
Line 114 in f5bb2e7
try passing ArrayBuffer instead of TypedArray like this:
...sendMessage('SAMFUI', "", jsbuff) -> ...sendMessage('SAMFUI', "", jsbuff.buffer)
with ArrayBuffers the API automatically supports all TypedArray variants, and even if data is copied into wasm heap byte by byte, c++ processor can simply cast the datatype into the type it expects.
Thanks
jsbuff.buffer returns the main Module.HEAPU8 ArrayBuffer. I don't want to send all of this over the messageport - what would you advise?
Module.HEAPU8.slice($1, $1 + $2) did the trick