Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix crash on source resize while Replay Buffer is active (#166)#179

Open
romanrafael12 wants to merge 1 commit into
exeldro:master from
romanrafael12:master
Open

Fix crash on source resize while Replay Buffer is active (#166) #179
romanrafael12 wants to merge 1 commit into
exeldro:master from
romanrafael12:master

Conversation

@romanrafael12

@romanrafael12 romanrafael12 commented May 19, 2026

Copy link
Copy Markdown

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 the obs_view / video_output
by calling obs_view_remove() immediately on a size change — while the
encoder was still feeding from the old video_output and the replay
buffer output was still running. The encoder kept pulling frames from a
freed video_output, causing a use-after-free crash.

Three related issues:

  1. video_output destroyed while in useobs_view_remove() ran
    synchronously on a size change, even with outputs/encoder still active.
  2. encoder released while activeupdate_encoder() called
    obs_encoder_release() without checking obs_encoder_active() first
    (release_encoders() already does this check, so it was inconsistent).
  3. race on async restart — new outputs could start (reusing the
    encoder) while a previous output was still being force-stopped.

The fix

  • On a size change with active outputs, only set restart = true and
    defer recreation. video_output is recreated only once outputs are
    down and the encoder is idle.
  • update_encoder() no longer releases an active encoder, and re-points
    the encoder to the current video_output when reusing an idle one.
  • The output-start path waits until any previous encoder has fully wound
    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!

Copy link
Copy Markdown
Author

For folks watching this PR who need the fix today, I've published
precompiled builds (Windows x64 and macOS Apple Silicon) on my
fork's Releases page while this is in review:

https://github.com/romanrafael12/obs-source-record/releases/tag/v0.4.8-rafael-1

Stress-tested on Windows (37 min, 100+ saves, 8 simultaneous
filters) and verified on macOS (multiple filters, rapid hotkey
saves across two video sources, clean recovery from the encoder
restart scenario described in the fix). Builds will be deprecated
in favor of upstream once this merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

AltStyle によって変換されたページ (->オリジナル) /