emscripten-core / emscripten-core/emscripten
How can I do synchronous fetches in Emscrpten
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
I want to use the synchronous acquisition of the emscripten fetch api in the main thread.When I set the compilation parameters according to the document prompts, the compilation will report an error. Refer to documentation :https://emscripten.org/docs/api_reference/fetch.html#synchronous-fetches
Compile parameters:
-s FETCH=1 -s STACK_OVERFLOW_CHECK=1 -s ALLOW_MEMORY_GROWTH=1 -s PTHREAD_POOL_SIZE_STRICT=0 -s PTHREAD_POOL_SIZE=100 -s DETERMINISTIC=1 --profiling-funcs -g -s USE_PTHREADS=1 --proxy-to-worker
problem 1:
em++: error: -sMODULARIZE is not compatible with --proxy-to-worker (if you want to run in a worker with -sMODULARIZE, you likely want to do the worker side setup manually)
Modify the compilation parameters and compile according to the above prompts. The following error occurs.
Compile parameters:
-s FETCH=1 -s STACK_OVERFLOW_CHECK=1 -s ALLOW_MEMORY_GROWTH=1 -s PTHREAD_POOL_SIZE_STRICT=0 -s PTHREAD_POOL_SIZE=100 -s DETERMINISTIC=1 --profiling-funcs -g -s USE_PTHREADS=1 --proxy-to-worker -s MODULARIZE=0
problem 2:
#error "--proxy-to-worker is not supported with -sUSE_PTHREADS>0! Use the option -sPROXY_TO_PTHREAD if you want to run the main thread of a multithreaded application in a web worker."
Modify the compilation parameters and compile according to the above prompts. The following error occurs.
Compile parameters(--proxy-to-worker replaced with -s PROXY_TO_PTHREAD=1):
-s FETCH=1 -s STACK_OVERFLOW_CHECK=1 -s ALLOW_MEMORY_GROWTH=1 -s PTHREAD_POOL_SIZE_STRICT=0 -s PTHREAD_POOL_SIZE=100 -s DETERMINISTIC=1 --profiling-funcs -g -s USE_PTHREADS=1 -s PROXY_TO_PTHREAD=1
problem 3:
Can be compiled successfully,However, an error is reported when accessing the page, such as:
worker.js onmessage() captured an uncaught exception: TypeError: Cannot read properties of undefined (reading 'InstallTrigger')
@kripken So what can we do to support synchronous extraction using the fetch api in the main thread?
Contributor guide
Assessment
This issue has not been assessed yet.