kira
kira copied to clipboard
Dropping `AudioManager` panics on Android
The minimal reproducing steps are simply dropping a AudioManager.
PanicInfo { payload: Any { .. }, message: Some(called `Option::unwrap()` on a `None` value), location: Location { file: "~/.cargo/registry/src/github.com-1ecc6299db9ec823/kira-0.7.1/src/manager/backend/cpal/desktop/stream_manager/renderer_wrapper.rs", line: 40, col: 9 }, can_unwind: true }
Currently this issue is temporarily fixed by implementing the Drop trait for the oboe backend of cpal (host/oboe/mod.rs):
impl Drop for Stream {
fn drop(&mut self) {
match self {
Self::Input(stream) => {
stream.borrow_mut().stop();
stream.borrow_mut().close();
}
Self::Output(stream) => {
stream.borrow_mut().stop();
stream.borrow_mut().close();
}
}
}
}
Not sure if this is an issue of cpal.
I don't currently have a dev environment for compiling Rust code for Android. I can work on setting one up, but in the meantime, can you get a stacktrace for that panic?
I don't currently have a dev environment for compiling Rust code for Android. I can work on setting one up, but in the meantime, can you get a stacktrace for that panic?
For some reason I was unable to get a concrete stacktrace. I debugged the program and here's roughly the call stack:
oboe::AudioStream::fireDataCallback(oboe/src/common/AudioStream.cpp:63)StreamManager audio output stream callbackhttps://github.com/tesselode/kira/blob/dc66cd995c5b522ba68f20a305bc43f4e6ab718d/crates/kira/src/manager/backend/cpal/desktop/stream_manager.rs#L130RendererWrapper deref()https://github.com/tesselode/kira/blob/dc66cd995c5b522ba68f20a305bc43f4e6ab718d/crates/kira/src/manager/backend/cpal/desktop/stream_manager/renderer_wrapper.rs#L34
Here the renderer is already taken by drop and thus the program panics.
@Mivik it seems like cpal is using Kira's stream manager after dropping it, which would be a bug in cpal. I'd open an issue in their repo and see what they say.