From 57b4bca7cb2e109baa650788ec88ccc2b676b153 Mon Sep 17 00:00:00 2001 From: adrdsouza <102761952+adrdsouza@users.noreply.github.com> Date: Sat, 17 Oct 2026 17:55:28 +0530 Subject: [PATCH] Use aborting WebAudio callbacks with unwinding enabled --- src/host/webaudio.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/host/webaudio.rs b/src/host/webaudio.rs index 422fa26de..16539cd75 100644 --- a/src/host/webaudio.rs +++ b/src/host/webaudio.rs @@ -1,6 +1,7 @@ //! Web Audio backend implementation. //! //! Default backend on WebAssembly. +//! Audio callbacks abort on panic because user callbacks need not be unwind-safe. extern crate js_sys; extern crate wasm_bindgen; @@ -401,7 +402,7 @@ impl DeviceTrait for Device { let current_time_bits_cb = current_time_bits.clone(); let on_audio_process = - Closure::wrap(Box::new(move |event: AudioProcessingEvent| { + Closure::wrap_aborting(Box::new(move |event: AudioProcessingEvent| { let now = ctx_cb.current_time(); #[cfg(target_feature = "atomics")] current_time_bits_cb.store(now.to_bits(), Ordering::Relaxed); @@ -703,7 +704,7 @@ impl DeviceTrait for Device { on_ended_closure .write() .unwrap() - .replace(Closure::wrap(Box::new(move || { + .replace(Closure::wrap_aborting(Box::new(move || { let now = ctx_handle.current_time(); // Keep the shared clock up to date so Stream::now() has a fresh value. @@ -1107,7 +1108,7 @@ impl DeviceTrait for Device { }; let on_audio_process = - Closure::wrap(Box::new(move |event: AudioProcessingEvent| { + Closure::wrap_aborting(Box::new(move |event: AudioProcessingEvent| { let now = ctx_cb.current_time(); #[cfg(target_feature = "atomics")] current_time_bits_cb.store(now.to_bits(), Ordering::Relaxed);