emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.6k stars 3.28k forks source link

Cannot Rendering and calling to Fetch API Sync in the main thread #16760

Open aharondavid opened 2 years ago

aharondavid commented 2 years ago

For using in EMSCRIPTEN_FETCH_SYNCHRONOUS, we should link with: USE_PTHREADS, PROXY_TO_PTHREAD, ALLOW_MEMORY_GROWTH. My main thread do the following: 1) GL rendering (that can be run only in the main thread as far as I understand). 2) calling to emscripten_fetch with EMSCRIPTEN_FETCH_SYNCHRONOUS.

The result: emscripten_fetch successed. Rendering is failed in its initialization.

The reason of failing, I supposed, it because that the rendering is pass to Worker thread due to the above linker flags. so, what should I do in such case when the main thread do a rendering and others pthread calling

Version of emscripten/emsdk: emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.4 (14cd48e6ead13b02a79f47df1a252abc501a3269) clang version 15.0.0 (https://github.com/llvm/llvm-project ce5588fdf478b6af724977c11a405685cebc3d26) Target: wasm32-unknown-emscripten Thread model: posix

sbc100 commented 2 years ago

Have you looked into the OFFSCREENCANVAS_SUPPORT setting? I believe this is required if you want to render from a worker.

aharondavid commented 2 years ago

I will test it. Thanks.

Vindfjall commented 6 months ago

Hi @aharondavid. I'm facing the same issue. Did you find any solution that worked? If you used OFFSCREENCANVAS_SUPPORT, did you have to do something more except from setting that flag? Thanks in advance!