emscripten-core / emscripten-core/emscripten
audioWorklets and libpd !emscripten_is_main_browser_thread issue
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
audioWorklets with Open Frameworks work really well, as long as I do not use ofxOfelia as an addon: https://github.com/cuinjune/Ofelia
If I use it with `USE_PTHREADS`, I get error messages like this:
```
Uncaught RuntimeError: Aborted(Assertion failed: !emscripten_is_main_browser_thread(), at: /mnt/c/Users/Jonat/emsdk/upstream/emscripten/system/lib/pthread/emscripten_futex_wake.c,35,emscripten_futex_wake)
at abort (index.js:783:40)
at ___assert_fail (index.js:4021:2)
at index.wasm.emscripten_futex_wake (index.wasm:0xd8a614)
at index.wasm.__wake.10 (index.wasm:0xd93fd7)
at index.wasm.__pthread_mutex_unlock (index.wasm:0xd93fbe)
at index.wasm.sys_unlock (index.wasm:0x3f1448)
at index.wasm.ofxOfelia::mouseDragged(ofMouseEventArgs&) (index.wasm:0x1cc4b)
at index.wasm.ofApp::mouseDragged(ofMouseEventArgs&) (index.wasm:0x1445c)
at index.wasm.std::__2::__function::__func> ofEvent::make_function(ofBaseApp*, void (ofBaseApp::*)(ofMouseEventArgs&), int)::'lambda'(void const*, ofMouseEventArgs&), std::__2::allocator> ofEvent::make_function(ofBaseApp*, void (ofBaseApp::*)(ofMouseEventArgs&), int)::'lambda'(void const*, ofMouseEventArgs&)>, bool (void const*, ofMouseEventArgs&)>::operator()(void const*&&, ofMouseEventArgs&) (index.wasm:0x45d3f4)
at index.wasm.ofEvent::notify(ofMouseEventArgs&) (index.wasm:0x463418)
```
If I comment out line 35 in `emscripten_futex_wake.c` it seems to work without issues: https://github.com/emscripten-core/emscripten/blob/main/system/lib/pthread/emscripten_futex_wake.c
But I wonder, if there is a cleaner way to resolve the assertion.
Probably it has to do with libpd's/Pure Data's own locking system(because there is always a `sys_unlock` involved)?
And maybe this issue is related: https://github.com/emscripten-core/emscripten/issues/14339?
Contributor guide
Assessment
This issue has not been assessed yet.