The crash was occurring because the WASAPI audio subsystem was still actively processing audio data from the browser source during OBS shutdown. This caused an access violation (c0000005) in copy_audio_data when it tried to access freed memory.
The browser source itself generates audio from web content (videos, audio elements, etc.). Even though the plugin doesn't directly handle audio, the browser source it creates is an audio-generating source that OBS's WASAPI system processes. The previous fix attempted to disconnect audio after creation, but the browser source was still initializing its audio components and registering with WASAPI.
The most important fix is to completely disable audio in the browser source settings BEFORE creation:
// CRITICAL FIX: Completely disable audio in browser source to prevent WASAPI crashes
obs_data_set_bool(settings, "reroute_audio", false);
obs_data_set_bool(settings, "muted", true); // Mute from creation
obs_data_set_int(settings, "audio_output_mode", 0); // 0 = No audio output
obs_data_set_bool(settings, "monitor_audio", false); // No audio monitoring
obs_data_set_bool(settings, "audio_output_to_stream", false); // Don't output audio to stream
obs_data_set_bool(settings, "audio_output_to_desktop", false); // Don't output audio to desktopThis prevents the browser source from ever initializing audio components that could crash during shutdown.
After creating the browser source, we triple-ensure audio is disabled:
obs_source_set_muted(m_banner_source, true);
obs_source_set_volume(m_banner_source, 0.0f);
obs_source_set_monitoring_type(m_banner_source, OBS_MONITORING_TYPE_NONE);
obs_source_set_audio_active(m_banner_source, false);
obs_source_update(m_banner_source, settings); // Force settings updateDuring emergency shutdown, we now:
- Navigate browser to
about:blankto stop all media playback - Set browser shutdown flag to trigger CEF cleanup
- Push empty audio frame to flush pending operations
- Wait with extended synchronization for WASAPI threads
- Source Protection Mutex
- Signal Disconnection
- Remove from ALL Scenes
- Extended Synchronization (350ms+ total)
- Memory Barrier
- Null-Before-Release
- Dedicated Cleanup Thread
- Prevention vs. Mitigation: Instead of trying to clean up audio after the fact, we prevent the browser source from ever initializing audio components
- Browser-Specific Cleanup: Navigate to blank page and set shutdown flag to stop media playback
- Comprehensive Settings: Use all available browser source audio settings to ensure complete disablement
- Applied to All Creation Paths: Updated all three locations where browser sources are created
- Install the updated plugin
- Add a browser source banner with video/audio content
- Let it play for a few seconds
- Exit OBS while content is playing
- OBS should shut down cleanly without crashes
By disabling audio at the browser source creation level and adding browser-specific cleanup procedures, we prevent the WASAPI audio system from ever processing audio from our browser sources, eliminating the crash during shutdown.