emscripten-core / emscripten-core/emscripten

Embind’ed processing with nested threads hangs.

Open
#15,698 0 comments 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

The minimal example and build instruction is here: https://github.com/amukovozov/embind_threading.

The code does simple arithmetical computations (as an example) without using any features like filesystem, canvases, or calling JS functions from C++ (except for what emscripten does itself), it is just a number-cruncher.

The example initializes the WASM module from a web-worker; without the worker (doing the same from the main browser thread) the same issue is observed, but it also blocks the main thread which is not convenient.

The example has 3 modes of computation: “no threads”, “flat”, and “nested”.
All modes perform the same processing on 2 arrays of numbers.
“No threads” mode does the processing sequentially. It works fine.
“Flat” mode spawns a thread for each value to process. It works fine.
“Nested” mode spawns 2 threads for an array, and each of those threads spawns a thread for each value in the half of that array. It gives a warning in the console that says `Tried to spawn a new thread, but the thread pool is exhausted` and never finishes execution. However, the total number of spawned threads should never exceed the pool size by design of the example.

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.