Replies: 1 comment
-
When you build with For emscripten/system/lib/gl/webgl1.c Line 133 in 4b76531 This definition uses emscripten/system/lib/gl/webgl_internal.h Line 26 in 4b76531 This looks like the function will run on the worker thread if I'm not sure that will solve your problem but it might help you debug? |
Beta Was this translation helpful? Give feedback.
-
Hi.
After not receiveing any answer in the "Issues" list I am asking for help with this problem here.
I am writing a rendering app. I need it to run in a secondary thread in order not to interfere with UI.
My linker config is as follow:
-sINITIAL_MEMORY=134217728 -sMAX_WEBGL_VERSION=2 -sWASM=1 -sFULL_ES3 -sASYNCIFY -sPROXY_TO_PTHREAD=1 -sOFFSCREEN_FRAMEBUFFER=1 -sOFFSCREENCANVAS_SUPPORT=1 -sNO_EXIT_RUNTIME=1 -lembind -sENVIRONMENT=web,worker -sUSE_PTHREADS=1 -sPTHREAD_POOL_SIZE=8 -lpthread -msimd128 -matomics -mbulk-memory
Inside my app I am creating webgl2 context with the following attributes:
I am not sure about the second one but it is probably not related to my problem.
Now, I have a function called Init() and Run(). Init() creates webgl context and makes it current. Run() creates renderable objects and launches render loop with emscripten_set_main_loop_arg(&Render, this, 0, 1);
If Run() gets called within the app, like this:
It all works, Stuff is rendering.
However,I need this function to be called via button press on the front end. For this I am using embind to expose the function to JS.
If I call Run() via JS it looks like the webgl context gets lost. Also in the callstack I can see that the code tries to execute the function on the main thread. And my context lives in the worker thread.
From what I understood in the docs, embind should work fine with worker proxing function calls into the worker thread. But here it doesn't look like that. It seems like embind is attempting to execute the function on the main thread, which is not what I want.
Can someone explain what's going on here? And if embind is not supposed to work in this mode, what is the alternative for setting a communication between this wasm app and JS?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions