WebAudio wasm build fails with wasm-bindgen panic=unwind closures

Open Beginner friendly
#1,394 1 comment 0 reactions 0 assignees View on GitHub

@bogusyogi is already working on this.

Since Oct 17, 2026.

  • #1403 by @bogusyogi — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
75/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust, wasm

Research direction

Start with src/host/webaudio/mod.rs and inspect the Closure::wrap callback described in the issue. Check how wasm-bindgen 0.2.129 handles unwind safety for this callback, then build cpal for wasm32-unknown-unknown with panic=unwind to confirm the failure and verify the supported closure construction. Done when that build succeeds with the callback owned by the WebAudio host.

Written by the indexing model from the issue text.

Description

host - webaudio platform - web

With Rust panic=unwind and current wasm-bindgen (0.2.129), cpal 0.18.2 fails to compile for wasm32-unknown-unknown in src/host/webaudio/mod.rs at Closure::wrap(Box::new(move || { ... })). The boxed callback type Box<dyn FnMut()> does not implement wasm-bindgen's MaybeUnwindSafe bound.

A local one-line fix is:

Closure::wrap_assert_unwind_safe(Box::new(move || { ... }))

The callback is owned by the WebAudio host and does not cross Rust threads. Would you consider this change, or another supported closure construction, in cpal?

Dominant language
Rust
Stars
4k
Forks
554
Avg merge
1d 3h
Merged PRs (30d)
1

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RustAudio/cpal

All issues in RustAudio/cpal

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.