Repository navigation
libobs: Finish the stop of an output stopped while reconnecting - #3935
Merged
Merged
Conversation
A stream through the FFmpeg muxer to a server that does not answer (an SRT address, from OBS or from source-record) fails to connect, and libobs waits to reconnect. A stop in that wait resets the stopping event and calls ffmpeg_mux_stop(), which only sets a flag: the stop ends with the next packet, and an output whose data capture has ended gets none. Nothing signals the stopping event, and obs_output_destroy() waits on it forever: OBS does not exit. The test fails a started output with OBS_OUTPUT_DISCONNECTED and a long retry delay, stops it while it waits to reconnect, and releases it, in a child process with a watchdog. RED with production 6d29998 (hybrid) and upstream OBS 33.0.1: the stop that only sets a flag hangs; a stop that signals itself when the output is not active (rtmp_output) and a stop of a connected output finish, each with one "stop" signal. Refs #3933, #3739 Co-Authored-By: Claude Opus 5.5 <[email protected]>
A stream through the FFmpeg muxer to a server that does not answer (an SRT address, from OBS or from source-record) fails to connect, and libobs waits to reconnect. A stop in that wait resets the stopping event, joins the reconnect thread and calls the output's stop. ffmpeg_mux_stop() only sets a flag: the stop ends with the next packet, and an output whose data capture ended with the failure gets none. Nothing signals the stopping event, and obs_output_destroy() waits on it forever: OBS does not exit. obs_output_actual_stop() now finishes the stop of an output that was reconnecting when the output's stop left it stopping and inactive: it signals "stop" and the stopping event, as it already does for a delayed output. An output whose stop ends the stop itself (rtmp_output signals its stop when it is not active) is left alone, so "stop" comes once. test_output_stop_while_reconnecting: hybrid and C libobs, built from this branch on Linux. Without the change the stop that only sets a flag hangs (watchdog); with it all three cases stop, are destroyed and signal "stop" once. test_output_stop_without_packets still passes with both. Refs #3933, #3739 Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=f8b673e69d66e95db03a750e3517245ed6c32f64 secs=422 lanes=lint:run,dylint:run,rust-test:run,cross:run,tier2-linux:run,macos-native:n/a,windows-native:n/a Ci-Attestation: {"at":1794081347,"gate":"rust/all/fmt","host":"linux-x86_64","key":"735588b5d71e8b893e7af685018c8c339b33f2b65fd3b67f9b03cb0dcc58c198","lane":"lint","parents":["e51b60dbf5d2b3f8f0bd6697e22b9e28d3a77a6c"],"secs":112,"stamp":"48efa82b313263408055abcdb98dddfc","tree":"f8b673e69d66e95db03a750e3517245ed6c32f64","v":1,"via":"run"} Ci-Attestation: {"at":1794081347,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"735588b5d71e8b893e7af685018c8c339b33f2b65fd3b67f9b03cb0dcc58c198","lane":"lint","parents":["e51b60dbf5d2b3f8f0bd6697e22b9e28d3a77a6c"],"secs":112,"stamp":"c1ecd32182e2b5b6b30a418ad634aa51","tree":"f8b673e69d66e95db03a750e3517245ed6c32f64","v":1,"via":"run"} Ci-Attestation: {"at":1794081347,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"1df69adc6b5088f88555479c0b91765f5d3ab4c786e09ee5b88e165cafc02eb7","lane":"rust-test","parents":["e51b60dbf5d2b3f8f0bd6697e22b9e28d3a77a6c"],"secs":157,"stamp":"a311dd3819aac077de84a057a72984e5","tree":"f8b673e69d66e95db03a750e3517245ed6c32f64","v":1,"via":"run"} Ci-Attestation: {"at":1794081347,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"067317ea1cd956382c44e69a59226b66fe968011b6a987809467b7981747c9c0","lane":"cross","parents":["e51b60dbf5d2b3f8f0bd6697e22b9e28d3a77a6c"],"secs":147,"stamp":"5dd52b818896add749fb3455b6b75ce1","tree":"f8b673e69d66e95db03a750e3517245ed6c32f64","v":1,"via":"run"} Ci-Attestation: {"at":1794081347,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"067317ea1cd956382c44e69a59226b66fe968011b6a987809467b7981747c9c0","lane":"cross","parents":["e51b60dbf5d2b3f8f0bd6697e22b9e28d3a77a6c"],"secs":147,"stamp":"ed431a0aac946f42f1a279e57fa7bde8","tree":"f8b673e69d66e95db03a750e3517245ed6c32f64","v":1,"via":"run"} Ci-Attestation: {"at":1794081347,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"067317ea1cd956382c44e69a59226b66fe968011b6a987809467b7981747c9c0","lane":"cross","parents":["e51b60dbf5d2b3f8f0bd6697e22b9e28d3a77a6c"],"secs":147,"stamp":"c793299a76e88682e714617c2178bc1a","tree":"f8b673e69d66e95db03a750e3517245ed6c32f64","v":1,"via":"run"} Ci-Attestation: {"at":1794081347,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"067317ea1cd956382c44e69a59226b66fe968011b6a987809467b7981747c9c0","lane":"cross","parents":["e51b60dbf5d2b3f8f0bd6697e22b9e28d3a77a6c"],"secs":147,"stamp":"9f11569beec351c665b77c08bfd38dea","tree":"f8b673e69d66e95db03a750e3517245ed6c32f64","v":1,"via":"run"} Ci-Attestation: {"at":1794081347,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"59bf5958ee73f27151231db6187c9222656d8eb994e9b9222e331d45031ae05b","lane":"tier2-linux","parents":["e51b60dbf5d2b3f8f0bd6697e22b9e28d3a77a6c"],"secs":410,"stamp":"06b1a958fbce2db34b8a14e084e65b27","tree":"f8b673e69d66e95db03a750e3517245ed6c32f64","v":1,"via":"run"}
vpacher
marked this pull request as ready for review
November 7, 2026 20:08
vpacher
enabled auto-merge
November 7, 2026 20:08
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 7, 2026
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.
Problem
A stream through the FFmpeg muxer to a server that does not answer (for example an SRT address, from OBS or from a Source Record filter) fails to connect, and libobs waits to reconnect. A stop in that wait goes to
obs_output_actual_stop(): it resets the stopping event, joins the reconnect thread and calls the output's stop.ffmpeg_mux_stop()only sets a flag, because the muxer ends a stop with its next packet. The data capture ended with the failure, so no packet comes. Nothing signals the stopping event, andobs_output_destroy()waits on it forever: OBS does not exit.Upstream OBS 33.0.1 and upstream master have the same code in
obs_output_actual_stop()andffmpeg_mux_stop(). The new test hangs with upstream 33.0.1 too.Reproduced in the app on Linux (Arch,
obs-studio-rust-gitr35):srt://10.255.255.1:9000?mode=caller, "Stop Streaming" while it waits to reconnect, then quit: hangs. The main thread waits inobs_output_release()->obs_output_destroy()->os_event_wait(stopping_event).Change
obs_output_actual_stop()now finishes the stop of an output that was reconnecting when the output's stop left it stopping and inactive: it signals "stop" and the stopping event, as it already does for a delayed output. An output whose stop ends the stop itself (rtmp_outputsignals its stop when it is not active) is left alone, so "stop" comes once.Tests
test/cmocka/test_output_stop_while_reconnecting.c, new): starts an output, fails it withOBS_OUTPUT_DISCONNECTEDand a long retry delay, stops it while it waits to reconnect and releases it, in a child process with a watchdog. Three cases: a stop that only sets a flag (ffmpeg_muxer), a stop that signals itself (rtmp_output), and a stop of a connected output (control). Each must stop, be destroyed and signal "stop" once.test_output_stop_without_packets(#3764) still passes with both builds. Built on Linux (Debian 13) from this branch, libobs and libobs-opengl, run under Xvfb.Local gate (b6baa23, stamped): lint, dylint, rust-test, cross and tier2-linux passed in 7 min; Tier 2 ran the new test in both modes (4.1 s C, 4.2 s hybrid).
Tiers: Tier 2 is the new cmocka test (hybrid and C reference). No Rust code changes, so Tier 1 and Tier 3 do not apply. Test cost: about 3 s per case (1 s of output, then the stop and release), one child process per case, no own threads in the test.
In the app (Arch,
obs-studio-rust-gitr35 rebuilt with only this change, same machine and harness as the reproduction):The logs show the stop right after "Reconnecting in 2.00 seconds..", with no connect attempt in between, and one "Streaming Stop".
Fixes #3933. Refs #3739: found while investigating it; the leftover
obs-studio-rust-ffmpeg-muxreported there is probably a different bug, so that issue stays open.🤖 Generated with Claude Code