Skip to content

Bound obs64 shutdown with a watchdog and free the exit pipe after ack - #1821

Open
summeroff wants to merge 1 commit into
stagingfrom
fix/obs64-shutdown-watchdog
Open

summeroff wants to merge 1 commit into
stagingfrom
fix/obs64-shutdown-watchdog

Conversation

@summeroff

@summeroff summeroff commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Problem: obs64 teardown had no deadline. A hang in obs_shutdown/CefShutdown or a stuck muxer left obs64 running after Desktop exited. Since 1.22 that leftover holds CEF's cache lock and crashes the next session's obs64 at startup. The exit-slobs-crash-handler pipe was also reconnected after the ack, so a leftover kept the name the next session needs.

Change (Windows only): a watchdog terminates obs64 when a stage overruns: 15 s before teardown, 30 s per output (up to 180 s while a recording finishes its file), 30 s for teardown. No Sentry report. obs64 also terminates itself once teardown completes, and the exit pipe is closed after the ack.

Effect: no obs64 left behind; recordings still get up to 180 s to finish.

Related: #1820, streamlabs/obs-browser#59

Tests

  • RelWithDebInfo builds obs64.exe and unit tests
  • node ci/run-unit-tests.js: 70/70, incl. 10 new watchdog tests (fake clock)
  • clang-format 18.1.3 clean
  • Hung obs_shutdown repro (cdb): self-terminated at 30 s, exit 0x0B5D0001, no crash report, pipe released; control run exited normally

Not verified: real-recording scenarios (exit while recording, slow muxer under cap, stuck muxer at cap), integration suite, macOS.

obs64 teardown had no deadline, so a hang left it running after Desktop exited, holding CEF's cache lock and the exit pipe name the next session needs. A watchdog now terminates it on overrun, and the pipe is closed after the ack.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Legacy recordings still risk process termination after 10 seconds instead of receiving the 180-second finalization allowance, while watchdog deadline resets can improperly extend preparation and teardown limits.

2 open issues
What changed in this PR

This PR adds Windows shutdown deadlines to reduce leftover obs64 processes that can hold CEF’s cache lock and block the next session.

Changes:

  • Adds a staged shutdown watchdog with output-finalization tracking and fake-clock tests.
  • Integrates watchdog budgets into shutdown and terminates obs64 after teardown.
  • Closes the exit pipe after acknowledgment instead of reconnecting it.
File Description
obs-studio-server/​tests/​test-shutdown-watchdog.cpp Tests deadlines, caps, disarming, and finalization tracking.
obs-studio-server/​source/​shutdown-watchdog.hpp Defines watchdog budgets and tracking interfaces.
obs-studio-server/​source/​shutdown-watchdog.cpp Implements deadline monitoring and Windows termination.
obs-studio-server/​source/​osn-output.hpp Adds per-output finalization tracking.
obs-studio-server/​source/​osn-output.cpp Tracks output stopping and completion signals.
obs-studio-server/​source/​nodeobs_api.cpp Integrates shutdown budgets and releases the exit pipe.
obs-studio-server/​source/​main.cpp Arms preparation monitoring and terminates after teardown.
obs-studio-server/​CMakeLists.txt Registers watchdog sources and tests.

Review effort: Balanced

Comment on lines +1669 to +1670
osn::ShutdownWatchdog::Instance().Arm("Outputs", osn::shutdown_budget::OutputStep);
osn::ShutdownWatchdog::Instance().SetCap(osn::shutdown_budget::OutputCap);
std::lock_guard lock(m_mtx);
m_finalizing += delta;
// Each output gets a fresh step once it finishes finalizing.
if (m_finalizing == 0 && delta < 0 && m_armed)
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