wasm: enable AudioWorklets with JSPI to fix no-sound on web#88
Closed
wasm: enable AudioWorklets with JSPI to fix no-sound on web#88
Conversation
- Add MA_ENABLE_AUDIO_WORKLETS define to enable miniaudio's AudioWorklet path for WASM builds - Add -sJSPI, -sAUDIO_WORKLET=1, -sWASM_WORKERS=1 emscripten flags - Remove -sMAIN_MODULE=1 (incompatible with -sWASM_WORKERS=1) - Remove emscripten_builtin_memalign exports (no longer needed without MAIN_MODULE) - Create src/platform/wasm/soluna_audio_wasm.js: override emscripten_request_animation_frame_loop to wrap the RAF callback with WebAssembly.promising() so that emscripten_sleep() called during miniaudio's audio worklet initialization uses JSPI suspension instead of throwing a SuspendError Co-authored-by: cloudwu <729648+cloudwu@users.noreply.github.com> Agent-Logs-Url: https://github.com/cloudwu/soluna/sessions/21adb45c-8735-4dda-8cd7-3ce5749dcbff
Copilot
AI
changed the title
[WIP] Fix sound issue in web version
wasm: enable AudioWorklets with JSPI to fix no-sound on web
Mar 25, 2026
Contributor
|
我尝试部署了这个分支, 结果一样有 |
Merged
Owner
|
问题已解决,并不需要这个方案。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Web audio was broken because miniaudio's AudioWorklet initialization calls
emscripten_sleep()in a spin-wait, which requires JSPI — but sokol's RAF callback (_sapp_emsc_frame_animation_loop) was not wrapped withWebAssembly.promising, causingSuspendError: trying to suspend without WebAssembly.promising.Changes
make.luaMA_ENABLE_AUDIO_WORKLETS(switches miniaudio from deprecated ScriptProcessorNode to AudioWorklets)-sJSPI,-sAUDIO_WORKLET=1,-sWASM_WORKERS=1-sMAIN_MODULE=1— incompatible with-sWASM_WORKERS=1src/platform/wasm/soluna_audio_wasm.js(new)Overrides
emscripten_request_animation_frame_loopto wrap the WASM frame callback withWebAssembly.promising(), making it a valid JSPI suspension point. Falls back to a synchronous call when JSPI is unavailable.During the first frame where
render_initruns, the audio worklet thread initializes asynchronously; eachemscripten_sleep(1)in miniaudio's spin-wait suspends the WASM stack via JSPI and yields to the browser event loop untilinitResulttransitions fromMA_BUSYtoMA_SUCCESS. Subsequent frames are unaffected.📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.