emscripten-core / emscripten-core/emscripten

Pthreads custom wrapper

Open
#14,452 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Hi @sbc100 @kripken

following our conversation on another issue https://github.com/emscripten-core/emscripten/issues/14312#issuecomment-854913896 , I am now building the ffmpeg with `-s ENVIRONMENT=worker -s BUILD_AS_WORKER=1`, on JS side I spin up my custom worker.js (that creates the module) and calls `module._main()`. I am able to call main, but I need to call it with pthread wrapper I guess.

When calling `module._main(argc, argv);`, I see console logging `Tried to spawn a new thread, but the thread pool is exhausted.` so I increased pool size `-s PTHREAD_POOL_SIZE=16`, but event after log errors are gone the further process / logs hangs and is never finished. So my guess I need to properly wrap `main()`?

I wonder if this is possible on JS side or needs to be done in C. I tried to copy over https://github.com/emscripten-core/emscripten/blob/bdc97fe0de1daf9e66aea4fa1d30b3dc3bd907c3/system/lib/pthread/library_pthread.c#L935-L951 into my ffmpeg.c where main() exists, but obviously that throws compiler errors. I am not a C developer, so if possible, I would like to handle as much as possible on JS side.

I have looked into https://github.com/emscripten-core/emscripten/blob/2.0.24/src/library_pthread.js if there is anything that would guide me but no luck so far.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.