mozilla / cubeb-coreaudio-rs

The audio backend of Firefox on Mac OS X.
ISC License
25 stars 10 forks source link

`close` the CoreStreamData if it fails to `setup` #140

Closed ChunMinChang closed 3 years ago

ChunMinChang commented 3 years ago

This should solve the crash on BMO 1708718.

By the crash reports, the MOZ_CRASH Reason (Sanitized) is register default_output_listener without unregistering the one in use. That means the assertion: https://github.com/mozilla/cubeb-coreaudio-rs/blob/5a5bc63d7ee37ea78adfa7c958d45b1595bf6c61/src/backend/mod.rs#L2984-L2987 in install_system_changed_callback is hit. The thread hitting the assertion is on coreaudio_sys_utils::dispatch::Queue::create_closure_and_executor::closure_executer so this crash is very likely to happen when running reinit (the stream is being reinitializing).

I managed to reproduce the crash by the comment here. If default_input_listener fails to be registered in the first setup: https://github.com/mozilla/cubeb-coreaudio-rs/blob/5a5bc63d7ee37ea78adfa7c958d45b1595bf6c61/src/backend/mod.rs#L3297 then default_output_listener is a Some when the second setup is called: https://github.com/mozilla/cubeb-coreaudio-rs/blob/5a5bc63d7ee37ea78adfa7c958d45b1595bf6c61/src/backend/mod.rs#L3312 and it ends up hitting the assertion since default_output_listener is not a None