Hanns Holger Rutz
unread,Dec 31, 2020, 7:21:59 AM12/31/20Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to emscripte...@googlegroups.com
Hi there,
I wonder what is the best way to pass a byte array from non-main-thread
C++ to main-thread JS. I'm hesitating to call MAIN_THREAD_SYNC_EM_ASM
because I don't want to block the C++ thread. So the next two options
are EM_ASM and MAIN_THREAD_ASYNC_EM_ASM. In the asynchronous case,
obviously I would have to malloc in C++ and free in JS. Is that
possible? In the EM_ASM case, JS doesn't have access to any regular
objects from the main JS environment. So I would have to copy the data
and defer to the main JS thread? I suppose there is one worker.js that I
would have to listen to from main, and use postMessage from within EM_ASM?
Also the data is bounded by 8K, could I perhaps use a different
approach, like use a constant size array direct passing somehow?
best, .h.h.