Skip to content

Fix encoder vs output shutdown crash#1635

Open
aleksandr-voitenko wants to merge 2 commits intostagingfrom
fix-encoder-vs-output-shutdown-crash
Open

Fix encoder vs output shutdown crash#1635
aleksandr-voitenko wants to merge 2 commits intostagingfrom
fix-encoder-vs-output-shutdown-crash

Conversation

@aleksandr-voitenko
Copy link
Collaborator

@aleksandr-voitenko aleksandr-voitenko commented Mar 6, 2026

Description

This PR reduces shutdown-time crashes in obs-studio-node by making shutdown wait for all active outputs to fully stop before cleanup continues. The change is made in nodeobs_service.cpp and is intended to avoid races where streaming/recording resources are destroyed while OBS output threads are still active.

The stack trace from Sentry. See, for example an issue with ID 2a0f8364

w32-pthreads +0x05277   pthread_mutex_unlock (pthread_mutex_unlock.c:61)
KERNELBASE   +0xc37ea   ResetEvent
obs          +0x6439d   gpu_encode_thread (obs-video-gpu-encode.c:126)

The stack trace is not really meaningful, but logs associated with the issue are the real source of insight.

What changed

  • Improved stopStreaming(...) to handle nullptr outputs safely and to treat connecting as a busy state instead of assuming only active/reconnecting matter.
  • Added shutdown helpers that detect whether an output is still busy and block shutdown until all relevant outputs have stopped.
  • Updated stopAllOutputs() to:
    • wait for any prior release worker to finish,
    • stop stream outputs gracefully,
    • stop replay buffer, recording, and virtual camera outputs if still busy,
    • wait until all outputs are no longer active/connecting/reconnecting,

How Has This Been Tested?

Manually, Windows only.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants