Fix crash on source resize while Replay Buffer is active (#166)#179
Open
romanrafael12 wants to merge 1 commit into
Open
Fix crash on source resize while Replay Buffer is active (#166)#179romanrafael12 wants to merge 1 commit into
romanrafael12 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi exeldro,
I ran into the crash described in #166 and tracked down the cause.
This PR fixes it.
The problem
When a source's resolution changes while a Source Record filter has
the Replay Buffer enabled (for example, tabbing in/out of a window
capture), OBS crashes.
source_record_filter_tick()recreated theobs_view/video_outputby calling
obs_view_remove()immediately on a size change — while theencoder was still feeding from the old
video_outputand the replaybuffer output was still running. The encoder kept pulling frames from a
freed
video_output, causing a use-after-free crash.Three related issues:
obs_view_remove()ransynchronously on a size change, even with outputs/encoder still active.
update_encoder()calledobs_encoder_release()without checkingobs_encoder_active()first(
release_encoders()already does this check, so it was inconsistent).encoder) while a previous output was still being force-stopped.
The fix
restart = trueanddefer recreation.
video_outputis recreated only once outputs aredown and the encoder is idle.
update_encoder()no longer releases an active encoder, and re-pointsthe encoder to the current
video_outputwhen reusing an idle one.down before starting new outputs.
44 lines changed; no behavior change for the normal start/stop path.
Testing
Tested on Windows with OBS 32.1.2. Ran 8 simultaneous Source Record
filters with Replay Buffer enabled for ~37 minutes — 100+ replay saves,
repeated scene switches and source resizes. No crashes, clean shutdown.
The same scenario reliably crashed before the patch.
Thanks for the plugin!