Repository navigation
linux-pipewire: Keep the streams of hidden screen captures paused - #1111
Merged
zackees merged 2 commits intoOct 16, 2026
Merged
Conversation
test_pipewire_screencast_resume gains three cases. Its fake compositor now links every capture stream to the monitor (each once, as before), and the test counts the frames each stream takes (pw_stream_dequeue_buffer, wrapped at link time). With a capture showing, a second one in a scene that is not live and a third disabled in a live scene, all three streams get the monitor's frames. Their streams connect active, and only a hide after a show pauses them, so the compositor copies every frame for every screen capture (obsproject/obs-studio#13836). RED: sources_not_showing_keep_their_streams_inactive fails, "frames in 2 s: showing capture 60, in another scene 60, disabled 60" (0 expected for the two that are not showing). Guards that pass today: showing_a_source_starts_its_stream (20 rounds of show, a new frame, hide, no more frames) and sources_not_showing_stay_inactive_after_reconnect (obs-rust#109: after the monitor comes back, only the showing capture streams). The four existing cases still pass. Upstream: obsproject/obs-studio#13836. Refs obs-rust#1110. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every Screen Capture (PipeWire) stream connected active. libobs calls .hide only when a showing source stops showing, so a source that was disabled or in a scene that is not live when its portal session finished kept streaming, and the compositor copied every frame for it. With several captures this lags the desktop and OBS (obsproject/obs-studio#13836). Our reconnect (obs-rust#109) already paused a replacement stream for a hidden source; the first connect did not. The capture now remembers whether libobs last showed or hid it, and connects its stream with PW_STREAM_FLAG_INACTIVE unless it is showing. show() starts the stream as before. A show_mutex keeps that flag and the stream's active state in step: show() and hide() run on the video thread, a stream is connected or swapped out on the main loop. It is taken before the graphics lock and streams_mutex; show() and hide() never hold either. The camera source connects the same way but is left alone: nobody has reported it, and pausing a never-shown camera would let the device stop, so its first show would wait for the camera to start where today it is already running. GREEN for obs-rust#1110 (RED 2d6eb0d: a source in another scene and a disabled one each got 60 frames in 2 s). Now 0 and 0, with 60 for the showing capture. Shown 20 times, such a source got a new frame each time, and hiding it stopped its frames. After a reconnect only the showing capture streams. Upstream: obsproject/obs-studio#13836. Fixes obs-rust#1110. Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 16, 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.
Fixes #1110
Upstream: obsproject/obs-studio#13836 (SkyKingPX; KalarianAthecila added the case of sources in other scenes). Follow-up of our #109, which already paused a hidden source's stream, but only after a reconnect.
What and why
A Screen Capture (PipeWire) source that is not showing (disabled, or in a scene that is not live) now keeps its screencast paused, so the compositor no longer copies every frame for it. Before, every screen capture streamed from the moment its portal session finished. With several captures this lags the desktop and OBS.
Cause
obs_pipewire_connect_stream()(plugins/linux-pipewire/pipewire.c) connected every stream active..hidepauses a stream, and libobs calls.hideonly when a showing source stops showing. The portal session finishes after the scene collection has loaded, so a source that was never shown never got a hide.In the release (0.1.0-beta.20261014 AppImage on a private nested Hyprland 0.56.2 with xdg-desktop-portal-hyprland, its own PipeWire and WirePlumber, and one 1920x1080 headless output at 60 Hz with a clock window. A picker script answers the portal. Scene Live (current) holds a colour source, CapLive and CapDisabled with its item disabled; scene Other (not live) holds CapOther. All three capture the same output. Frames per screencast are counted from the portal's verbose log, CPU from
/procover 10 s, both stacks on the same machine):linux-pipewire.sosuspended, 0 fpsIn a first release run (same setup) the three screencasts ran at ~31 fps each with Hyprland at 24.0% and OBS at 24.9%. Switching Live away and back there left only the showing source's screencast running (14.5% / 13.1%): the hide path already worked.
Fix (all in
plugins/linux-pipewire)obs_pipewire_connect_stream_info.inactive: connect the stream withPW_STREAM_FLAG_INACTIVE.obs_pipewire_stream_show()starts it, as before.screencast-portal.c: the capture keepsshowing, set by its.showand.hidecallbacks, and connects a new stream inactive unless it is showing. This covers the first connect and every reconnect, so the reconnect-only hide from plugins: Reconnect Linux capture after PipeWire restarts #109 is gone. A newshow_mutexkeepsshowingand the stream's active state together..show/.hiderun on the video thread, and the main loop connects a stream or swaps it out (destroy_live_stream(), the stream held during a reconnect) under the same lock. Without it, a show between reading the state and storing the new stream would be lost and the source would stay black.show_mutexis taken before the graphics lock andstreams_mutex, and.show/.hidehold neither (libobs ticks sources outside the graphics context).Not changed
camera-portal.c) connects the same way. It is left alone: nobody has reported it, and pausing a camera before its first show would let the device stop, so the first show would wait for the camera to start where today it is already running.streamedcheck inreconnect-policy.c). A paused stream does not stream until it is shown, but a compositor that ends a screencast removes its node, and that is still handled.RED → GREEN
test/cmocka: Screen captures that are not showing get frames.test_pipewire_screencast_resumegets three cases. The fake compositor now links every capture stream to its monitor (each once, as before), and the test counts the frames each stream takes (pw_stream_dequeue_bufferwrapped at link time). In both lanes:sources_not_showing_keep_their_streams_inactivefails: "frames in 2 s: showing capture 60, in another scene 60, disabled 60". The two sources that are not showing should get 0.showing_a_source_starts_its_stream(20 rounds: change the picture while hidden, show, wait for the new picture, hide, no more frames) andsources_not_showing_stay_inactive_after_reconnect(plugins: Reconnect Linux capture after PipeWire restarts #109: after the monitor goes away and comes back, 1 stream gets frames and 2 are paused, then the reconnected hidden source streams when shown).ENABLE_RUST_LIBOBSOFF and ON): "showing capture 60, in another scene 0, disabled 0". Without a display all 7 cases skip. In this test the first new frame after a show takes 216-235 ms on average, against 114-122 ms on master. Here every capture shares one producer, and on master the never-shown capture keeps it running. With one other capture kept streaming, the branch takes 95 ms. The product numbers above come from per-source screencasts, as on a desktop.-j8(private Xvfb, systemlibobs-openglmasked, TMPDIR unset): 266/266 in each lane. Skipped cases in each lane:open_crashes_without_obs_core(intest_audio_ioandtest_video_io, as on master),test_alloc_count_stable_after_startup(test_startup_alloc_stable, under load) andtest_startup_shutdown_cycles(test_startup_cycle_stress). This branch changes neither. All PipeWire/Pulse tests ran. clang-format 22.1.3, gersemi 0.25.0 andci/test_registration.pyare clean.linux-pipewire.soin the 0.1.0-beta.20261014 AppImage.test_pipewire_screencast_resumeis already registered for Linux. It skips wherepipewireis not installed, as before. The new link option (-Wl,--wrap=pw_stream_dequeue_buffer) applies only to this test.Checklist
master-W..., ratchets): none (a link option for one test)AI note: Claude Code (Claude Opus 5.5) wrote the code, the tests, 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