Repository navigation
frontend: Recording shutdown waits for the stop signal instead of polling the UI thread (#1283) - #1342
Merged
Conversation
zackees
enabled auto-merge
October 17, 2026 21:31
zackees
added a commit
that referenced
this pull request
Oct 17, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Oct 17, 2026
zackees
enabled auto-merge
October 17, 2026 21:55
…unning (RED, #1283) Adds test_recording_shutdown_wait (Qt-linked cmocka, QtCore only): a fake output signals stop/deactivate from another thread after 200 ms; the wait must end after it, a timer posted to the UI event loop must fire during the wait, and with no stop the timeout still ends the wait and force-stops. WaitForOutputToStop() is introduced with the current sleep-polling behaviour, so the two event-loop cases fail. Refs #1283
…ling the UI thread (GREEN, #1283) closeWindow() needs the recording finalized before it destroys the outputs, so the wait stays synchronous for it, but WaitForOutputToStop() now runs a nested QEventLoop (user input excluded) that ends on the output's "deactivate" signal (or "stop" once inactive), hopped to the UI thread with a queued invocation, or on a single-shot PreciseTimer at the unchanged 5 s timeout, after which the recording is force-stopped as before. Refs #1283
zackees
force-pushed
the
fix/1283-recording-shutdown-async
branch
from
October 17, 2026 22:16
d0631bd to
918e64c
Compare
This was referenced Oct 18, 2026
5 of 6 tasks
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.
Refs #1283 (parent #1273)
Problem
StopRecordingForShutdown()(frontend/widgets/RecordingShutdown.hpp) waited for the recording to stop by sleeping 10 ms at a time on the UI thread, up to 5 s, so quitting while recording froze the window for the whole wait.Callers
Only one:
OBSBasic::closeWindow()(frontend/widgets/OBSBasic.cpp.hpp), before it waits on its worker threads and later destroys the outputs (outputHandler.reset()). It needs the recording finalized before it continues, so the wait stays synchronous for this caller. Profile and scene-collection switches do not use this path. The existingtest_recording_shutdown(Tier 2, real libobs output) calls the 2-arg overload, which keeps the old polling wait for non-UI callers.Design
StopRecordingForShutdown(handler, timeout_ms, wait)is a new overload: graceful stop, thenwait(timeout_ms), then a forced stop if it did not stop. The timeout (5000 ms) and the timeout behaviour are unchanged.WaitForOutputToStop(signal_handler, timeout_ms, active)(new header-onlyRecordingShutdownWait.hpp, added to the frontend-widgets PCH) runs a nestedQEventLoopwithExcludeUserInputEvents, because the window is closing. The loop ends on:deactivatesignal, or onstoponceactive()is false. libobs signalsstopwhile the encoders are still flushing anddeactivatejust before it clearsactive, so this matches the old "wait until inactive" condition. An output that never began capturing sends onlystopand is already inactive.Qt::PreciseTimerat the timeout.QMetaObject::invokeMethod(..., Qt::QueuedConnection). libobs holds the signal mutex while it runs callbacks, so aftersignal_handler_disconnectno callback is still running. Checks still queued are dropped when the receiver QObject is destroyed.active()check, so a stop that comes before the wait starts is not missed.closeWindow()(thread waits, saving, then destroying the outputs) has to run after the recording is finalized. SplittingcloseWindowin two would change shutdown ordering for every other step.Test (new, no existing test edited)
test/cmocka/test_recording_shutdown_wait.cpp+tests.d/test_recording_shutdown_wait.cmake: Qt-linked (QtCore only, no display), soci_scopeselects the Qt lane (ci/linux_qt_frontend.shbuilds and runs every tests.d fragment that finds Qt6). A fake output signalsstopand thendeactivatefrom another thread after 200 ms:StopRecordingForShutdownwith this wait: a stuck recording is force-stopped once, and one that stops is notRED (9895d06,
WaitForOutputToStop= the old polling loop)GREEN (922f0a8)
I ran these locally by building the test by hand against the Nix QtCore 6.11, cmocka 2.0 and libobs's callback/util sources, not through CMake.
Only the Qt CI lane verifies
closeWindow()change and the PCH include compile in the realobs-studiofrontend targetI did not run the real app here: no manual quit-while-recording check. Hence "Refs" and not "Fixes".
./lintpasses. I added a docs/features.md ledger line (Fixed upstream bugs → Scenes and UI).