Skip to content

audioWorklets and libpd !emscripten_is_main_browser_thread issue #20617

@Jonathhhan

Description

@Jonathhhan

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<std::__2::shared_ptr<of::priv::Function<ofMouseEventArgs, std::__2::recursive_mutex>> ofEvent<ofMouseEventArgs, std::__2::recursive_mutex>::make_function<ofBaseApp>(ofBaseApp*, void (ofBaseApp::*)(ofMouseEventArgs&), int)::'lambda'(void const*, ofMouseEventArgs&), std::__2::allocator<std::__2::shared_ptr<of::priv::Function<ofMouseEventArgs, std::__2::recursive_mutex>> ofEvent<ofMouseEventArgs, std::__2::recursive_mutex>::make_function<ofBaseApp>(ofBaseApp*, void (ofBaseApp::*)(ofMouseEventArgs&), int)::'lambda'(void const*, ofMouseEventArgs&)>, bool (void const*, ofMouseEventArgs&)>::operator()(void const*&&, ofMouseEventArgs&) (index.wasm:0x45d3f4)
    at index.wasm.ofEvent<ofMouseEventArgs, std::__2::recursive_mutex>::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: #14339?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions