Skip to content

Let an orphaned obs64 decide whether to wait for the user - #1829

Merged
summeroff merged 3 commits into
fix/obs64-shutdown-watchdogfrom
fix/obs64-orphan-policy
Nov 4, 2026
Merged

summeroff merged 3 commits into
fix/obs64-shutdown-watchdogfrom
fix/obs64-orphan-policy

Conversation

@summeroff

Copy link
Copy Markdown
Contributor

Stacked on #1821.

Problem: When Desktop dies, obs64 waits on crash-handler's ack over one global exit pipe with no timeout, even if nothing is live. If crash-handler is dead it waits forever, and a leftover obs64 holding the pipe breaks the next session.

Change (Windows): obs64 reports live outputs (stream, record, replay buffer) to crash-handler via new OUTPUT_STATE = 6. Orphaned, it shuts down at once if idle, or on ack, or 5 s after crash-handler dies. Per-session exit pipe plus the legacy one. Ships together with the crash-handler PR.

Effect: No stuck obs64 after a crash; recordings still finalize.

Tests:

  • Build clean; node ci/run-unit-tests.js: server 78/78, client 126/126; clang-format 18.1.3 clean
  • Real MP4 repro with fake crash-handler: idle, ack, handler killed, no handler; MP4 valid via ffprobe

Not verified: outputs ending while kept alive (unit only), integration suite, macOS.

🤖 Generated with Claude Code

obs64 waited indefinitely on crash-handler's ack over one global exit pipe, even with nothing live, and a leftover obs64 holding that pipe broke the next session. It now reports live outputs to crash-handler, uses a per-session exit pipe, and stops waiting when idle or when crash-handler dies.

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

Activity polling can dereference freed manager objects after API teardown and unprotected legacy output pointers during concurrent replacement or release, creating critical crash risks.

2 open issues
What changed in this PR

This PR extends the shutdown watchdog work in #1821 so orphaned Windows obs64 processes can decide whether to wait for the crash-handler based on live outputs and handler availability.

Changes:

  • Tracks output activity and reports it through the new OUTPUT_STATE command.
  • Adds per-session exit pipes alongside legacy support, with immediate idle shutdown and a five-second grace period after crash-handler loss.
  • Adds unit tests for orphan shutdown decisions.
File Description
obs-studio-server/​tests/​test-orphan-policy.cpp Tests acknowledgement, idle outputs, and handler-loss timing.
obs-studio-server/​source/​osn-output.hpp Declares atomic output activity tracking.
obs-studio-server/​source/​osn-output.cpp Updates activity snapshots from output lifecycle signals.
obs-studio-server/​source/​orphan-policy.hpp Defines orphan wait and shutdown decisions.
obs-studio-server/​source/​nodeobs_service.cpp Marks output state dirty on legacy output signals.
obs-studio-server/​source/​nodeobs_api.h Declares output-state query and publishing methods.
obs-studio-server/​source/​nodeobs_api.cpp Implements state reporting, handler tracking, exit pipes, and orphan waiting.
obs-studio-server/​source/​main.cpp Publishes output state during the Windows main loop.
obs-studio-server/​CMakeLists.txt Registers the orphan policy header and tests.

Review effort: Balanced

summeroff and others added 2 commits November 3, 2026 12:13
…tracking

The crash-handler output-state poll walked registries whose objects are freed by destroyOBS_API while the main loop keeps running. Publishing is now gated by a mutex-guarded flag that destroy clears first. Legacy OBS_service outputs are no longer tracked: Desktop only starts the legacy virtual cam, which does not count as live.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@summeroff
summeroff merged commit a24adf0 into fix/obs64-shutdown-watchdog Nov 4, 2026
5 checks passed
summeroff added a commit that referenced this pull request Nov 17, 2026
…1852)

* Report a previous server that can't be stopped because it runs elevated (#1830)

* Report a previous server that can't be stopped because it runs elevated

A non-elevated Desktop cannot open, and so cannot kill, an elevated leftover obs64. That process holds CEF's cache lock, so browser sources are disabled for the session with no explanation. Record its PID and expose it via IPC.getUnkillableStaleServer() so the app can tell the user.

* Let an orphaned obs64 decide whether to wait for the user (#1829)

* Let an orphaned obs64 decide whether to wait for the user

obs64 waited indefinitely on crash-handler's ack over one global exit pipe, even with nothing live, and a leftover obs64 holding that pipe broke the next session. It now reports live outputs to crash-handler, uses a per-session exit pipe, and stops waiting when idle or when crash-handler dies.

* Report aborts and terminates on obs64 worker threads (#1850)

Terminate handlers are per-thread on MSVC and the SIGABRT handler is one-shot, so after obs_startup a worker-thread abort/terminate ran HandleCrash once, then its final abort() hit SIG_DFL and fast-failed with no crash report. The stack was also logged only after the log was captured.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* Clear output registries on destroy and count legacy outputs as live

destroyOBS_API deleted streaming/file-output wrappers but left their registry entries, so a re-init could poll freed pointers. AnyLiveOutput also ignored raw outputs started through the legacy OBS_service API, reporting no live output while one was running.

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

* Stop polling legacy OBS_service outputs for live state

releaseStreamingOutput frees and nulls those outputs on a worker thread with no lock shared with the main-loop poll, so reading them could touch a freed output. Desktop does not stream or record through OBS_service.
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.

3 participants