Repository navigation
frontend: Stop the recording before quitting instead of dropping its end - #781
Merged
Merged
Conversation
Quitting OBS while it records (File > Exit, Ctrl+Q, closing the window, SIGINT) drops the end of the recording. OBSBasic::closeWindow() leaves the recording running until applicationShutdown() destroys the outputs with outputHandler.reset(), and destroying an active output force-stops it: every frame the video encoder still holds (x264's lookahead and B-frames) is lost. Stop Recording stops the output gracefully and keeps them. RecordingShutdown.hpp holds StopRecordingForShutdown(), the step closeWindow() will run before the outputs are destroyed. For now it does what closeWindow() does today: nothing. test_recording_shutdown runs it on a real libobs output whose video encoder holds back 12 frames and which stops like obs-ffmpeg-mux, then releases the output as outputHandler.reset() does. Two cases fail: the frames the encoder held at the quit must reach the recording, and a recording that never finishes stopping must be force-stopped after the timeout instead of left running. Refs obs-rust#780. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Quitting OBS while it records (File > Exit, Ctrl+Q, closing the window, SIGINT; after "Yes" on the exit prompt too) cut the end off the recording. closeWindow() left the recording running until applicationShutdown() destroyed the outputs, and destroying an active output force-stops it: the frames the video encoder still held (x264's lookahead and B-frames, about 0.7 s at 30 fps with x264 veryfast) never reached the file. closeWindow() now stops an active recording the way Stop Recording does and waits until it has stopped, before it clears the scenes, so the file ends at the moment of the quit. The wait is bounded (5 s); a recording that has not stopped by then is force-stopped as before, so quitting never hangs on it. The UI's own stop handlers are disconnected first: the window is going away, and, as before, a quit does not show the "recording saved" message, error dialogs or start an Automatic Remux. Fixes obs-rust#780. Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=6ba684713a432673c599479d76e1e603cf5151f1 secs=524 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run Ci-Attestation: {"at":1792022746,"gate":"rust/all/fmt","host":"linux-x86_64","key":"0a69292d402b4f5f37c5022d24365d2924e8e59046662f5e2a649e14ec4e92c1","lane":"lint","parents":["feeb8685167a38697774a664a6565c9b03fc80b0"],"secs":61,"stamp":"d85c8b09c97006340403e981b314db35","tree":"6ba684713a432673c599479d76e1e603cf5151f1","v":1,"via":"run"} Ci-Attestation: {"at":1792022746,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"0a69292d402b4f5f37c5022d24365d2924e8e59046662f5e2a649e14ec4e92c1","lane":"lint","parents":["feeb8685167a38697774a664a6565c9b03fc80b0"],"secs":61,"stamp":"069bbdbabfc645ddbd38b461630d5ae0","tree":"6ba684713a432673c599479d76e1e603cf5151f1","v":1,"via":"run"} Ci-Attestation: {"at":1792022746,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"3497d4b9b95a979d44f2da102f9c07fac30403d157925b4cbfb7196712014667","lane":"rust-test","parents":["feeb8685167a38697774a664a6565c9b03fc80b0"],"secs":134,"stamp":"b9b2ac504cd40118b18569ced8ce739b","tree":"6ba684713a432673c599479d76e1e603cf5151f1","v":1,"via":"run"} Ci-Attestation: {"at":1792022746,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"da43a0e01d7c8cd75a3c390127eb24aceae5508a652b2f29d80fc1472e9e672c","lane":"cross","parents":["feeb8685167a38697774a664a6565c9b03fc80b0"],"secs":113,"stamp":"4106c50da674d34053f98722f8326d80","tree":"6ba684713a432673c599479d76e1e603cf5151f1","v":1,"via":"run"} Ci-Attestation: {"at":1792022746,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"da43a0e01d7c8cd75a3c390127eb24aceae5508a652b2f29d80fc1472e9e672c","lane":"cross","parents":["feeb8685167a38697774a664a6565c9b03fc80b0"],"secs":113,"stamp":"5dc0597f09f8347804cdeb241b2f81a7","tree":"6ba684713a432673c599479d76e1e603cf5151f1","v":1,"via":"run"} Ci-Attestation: {"at":1792022746,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"da43a0e01d7c8cd75a3c390127eb24aceae5508a652b2f29d80fc1472e9e672c","lane":"cross","parents":["feeb8685167a38697774a664a6565c9b03fc80b0"],"secs":113,"stamp":"a8952e435cad6390c07a5e76c750a6c8","tree":"6ba684713a432673c599479d76e1e603cf5151f1","v":1,"via":"run"} Ci-Attestation: {"at":1792022746,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"da43a0e01d7c8cd75a3c390127eb24aceae5508a652b2f29d80fc1472e9e672c","lane":"cross","parents":["feeb8685167a38697774a664a6565c9b03fc80b0"],"secs":113,"stamp":"13fa251abbbfbe2cbda1b031efa26f9c","tree":"6ba684713a432673c599479d76e1e603cf5151f1","v":1,"via":"run"} Ci-Attestation: {"at":1792022746,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"da43a0e01d7c8cd75a3c390127eb24aceae5508a652b2f29d80fc1472e9e672c","lane":"cross","parents":["feeb8685167a38697774a664a6565c9b03fc80b0"],"secs":113,"stamp":"aaed1be817cb8e38768da3f5de60f047","tree":"6ba684713a432673c599479d76e1e603cf5151f1","v":1,"via":"run"} Ci-Attestation: {"at":1792022746,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"da43a0e01d7c8cd75a3c390127eb24aceae5508a652b2f29d80fc1472e9e672c","lane":"cross","parents":["feeb8685167a38697774a664a6565c9b03fc80b0"],"secs":113,"stamp":"5f84e378b5af935ebbb38fa0e701d680","tree":"6ba684713a432673c599479d76e1e603cf5151f1","v":1,"via":"run"} Ci-Attestation: {"at":1792022746,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"4bfc67b49a755152d4986aa22659f14b8bb88b25390678719623f939ebe899ea","lane":"tier2-linux","parents":["feeb8685167a38697774a664a6565c9b03fc80b0"],"secs":216,"stamp":"62ba51bea89a0c68084105e5552b65a3","tree":"6ba684713a432673c599479d76e1e603cf5151f1","v":1,"via":"run"}
Member
|
Rebased onto master, set
|
zackees
force-pushed
the
fix/quit-recording-drain
branch
from
October 15, 2026 00:05
5ae7050 to
7c1f992
Compare
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.
Fixes #780
What and why
Quitting OBS while it records no longer cuts the end off the recording.
OBSBasic::closeWindow()(frontend/widgets/OBSBasic.cppline 1840) left the recording running untilapplicationShutdown()destroyed the outputs withoutputHandler.reset()(line 1334). Destroying an active output force-stops it, so every frame the video encoder still held (x264's lookahead and B-frames) was lost: about 0.7 s at 30 fps with x264 veryfast. Stop Recording does not lose them, becauseobs_output_stop()lets the muxer write everything up to the moment of the stop.closeWindow()now stops an active recording the way Stop Recording does, right after the virtual camera and before the scenes are cleared, and waits until it has stopped. The wait is bounded: after 5 s the recording is force-stopped as before (with a warning in the log), so quitting never hangs on it.StopRecordingForShutdown()is a header template next toStopVirtualCamForShutdown(), so the test runs it without the frontend.stopRecording/recordStoppinghandlers are disconnected first. The window is going away, and, as before, a quit shows no "Recording saved" message or error dialog and starts no Automatic Remux.Reproduced in release v0.1.0-beta.20261014 (AppImage, headless: private Xvfb, private HOME,
dbus-run-session,--multi). Simple output, x264 Small (veryfast), MKV, 640x360 at 30 fps, a looping Media Source, recording started over obs-websocket and run for 10 s:On the branch the graceful stop took 0.9 s of the quit on this machine (software GL, heavily loaded); the 5 s limit was never reached.
RED → GREEN
test/cmocka: Add failing test for quitting OBS while recording.test_recording_shutdownrunsStopRecordingForShutdown()(in the RED commit it does whatcloseWindow()does today: nothing) on a real libobs output whose video encoder holds back 12 frames and which stops like obs-ffmpeg-mux, then releases the output asoutputHandler.reset()does. 2 of 3 cases fail in both lanes:test_quit_keeps_frames_held_by_encoder(42 frames into the encoder before the quit, 30 reach the output) andtest_quit_does_not_hang_on_stuck_recording(a recording that never finishes stopping is left running).test_quit_without_recordingpasses (no handler, no active recording).ENABLE_RUST_LIBOBSOFF and ON (43 packets for 42 frames; the stuck recording is force-stopped after 301 to 302 ms of a 300 ms limit); timing, so repeated 20 times per lane: 20/20. Needs core video, so the two libobs cases skip without a display (checked withDISPLAYunset). Full ctest (private Xvfb, systemlibobs-openglmasked, TMPDIR unset): 221/221 in both lanes, every PipeWire/PulseAudio test ran; skipped onlyopen_crashes_without_obs_coreand (Rust lane)test_startup_shutdown_cycles, as on master here. (A first Rust-lane run hadtest_startup_cycle_stressreported failed after its case skipped, from xvfb-run's teardown ("kill: No such process"); the rerun passed.) clang-format, gersemi andci/test_registration.pyclean.Checklist
master-W..., ratchets): noneAI note: Claude Code (Claude Opus 5.5) wrote the code, the test, the commit messages and this text under the submitter's direction, and ran the tests above on the submitter's machines.
🤖 Generated with Claude Code