Repository navigation
linux-capture: XComposite backs off the window search while the window is unmapped (#1357) - #1366
Merged
Merged
Conversation
…pped (#1357) While the captured window was not viewable (minimized, other workspace) the tick searched the client list and rebuilt the pixmap and watcher every 2 s forever. Now a search that finds the same, still unmapped window rebuilds nothing, and the interval doubles 2 -> 30 s. MapNotify/ConfigureNotify (via the watcher's window_changed), new settings and a successful capture reset it, so recovery is as fast as before. Refs #1357
zackees
enabled auto-merge
October 17, 2026 23:27
zackees
added a commit
that referenced
this pull request
Oct 18, 2026
…f a round trip per frame (#1356) xcompcap_video_tick called xcomp_window_exists (xcb_get_window_attributes request + reply) once or twice per frame under obs_enter_graphics and the source lock. The watcher now feeds Map/Unmap/DestroyNotify into a cached presence state; the tick reads the cache, reads events with the non-blocking xcb_poll_for_event (and frees them), and asks the server only after window_changed/new settings and at most once a second as a safety net, before obs_enter_graphics. #1366's search backoff is unchanged. Refs #1356
zackees
added a commit
that referenced
this pull request
Oct 18, 2026
…f a round trip per frame (#1356) xcompcap_video_tick called xcomp_window_exists (xcb_get_window_attributes request + reply) once or twice per frame under obs_enter_graphics and the source lock. The watcher now feeds Map/Unmap/DestroyNotify into a cached presence state; the tick reads the cache, reads events with the non-blocking xcb_poll_for_event (and frees them), and asks the server only after window_changed/new settings and at most once a second as a safety net, before obs_enter_graphics. #1366's search backoff is unchanged. Refs #1356
chriscoveries
pushed a commit
to chriscoveries/obsrust-fork
that referenced
this pull request
Oct 18, 2026
…f a round trip per frame (obs-rust#1356) (obs-rust#1377) * test(linux-capture): RED, XComposite asks the X server whether its window exists every frame (obs-rust#1356) Pure presence helpers stubbed to today's behaviour (a round trip per tick, events ignored); the new cmocka test counts round trips. Refs obs-rust#1356 * linux-capture: XComposite tracks window state from X events instead of a round trip per frame (obs-rust#1356) xcompcap_video_tick called xcomp_window_exists (xcb_get_window_attributes request + reply) once or twice per frame under obs_enter_graphics and the source lock. The watcher now feeds Map/Unmap/DestroyNotify into a cached presence state; the tick reads the cache, reads events with the non-blocking xcb_poll_for_event (and frees them), and asks the server only after window_changed/new settings and at most once a second as a safety net, before obs_enter_graphics. obs-rust#1366's search backoff is unchanged. Refs obs-rust#1356 * docs(features): XComposite window state from X events (obs-rust#1377) Refs obs-rust#1356 * test(linux-capture): XComposite capture follows map/unmap/destroy end to end under Xvfb (obs-rust#1356) Compiles the linux-capture unity file into a cmocka test, publishes a minimal EWMH setup in place of a window manager, and drives a plain xcb window through map, three unmap/map rounds and destroy while libobs ticks the real xcomposite source. Unmap must unhook within 400 ms (well under the 1 s safety net, so it comes from the UnmapNotify read by xcb_poll_for_event), map must re-hook within 2 s, destroy must unhook. Xvfb's llvmpipe cannot import the window pixmap as an EGLImage, so the capture's texture is not checked; the hooked state is. Refs obs-rust#1356
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 #1357 (parent #1273). No closing keyword: the real app was not run.
Cause
xcompcap_video_ticktreats a non-viewable window (minimized, other workspace) as lost. Every 2 s (FIND_WINDOW_INTERVAL), underobs_enter_graphics(), it ranxcomp_find_window(client list + per-window name/class round trips) and tore down/recreated the watcher and pixmap, even when the search returned the same XID. Forever.Design
Decision factored into pure static inline helpers in
plugins/linux-capture/xcomposite-search.h(included via the group PCH):xcomp_search_due: search at once whenwindow_changed(watcher saw Map/Configure/Expose/Visibility/Destroy on the target), else when lost and the interval has passed.xcomp_search_needs_rebuild: no watcher/pixmap rebuild when the search found the same XID and it is still not viewable (and not forced).xcomp_search_done: interval doubles 2 -> 4 -> 8 -> 16 -> 30 s cap on a miss; resets to 2 s on capture or a forced search.xcompcap_update(settings) resets it too.Recovery: MapNotify reaches the watcher (already subscribed with StructureNotifyMask on the unmapped window), sets
window_changed, and the next tick searches and rebuilds immediately, as today. A new XID (relaunched app) still rebuilds; DestroyNotify resets the backoff.Tests
New
test/cmocka/test_xcomposite_search_backoff.c(tests.d fragment, cmocka only, no X): 60 s of simulated 1/60 s ticks with the window unmapped -> 3..6 searches (old: 29), 0 rebuilds; map event resets; window_changed forces an immediate search; rebuild rules.4 FAILED TEST(S), 1 of 293 failed.rust/tools/linux-validate/run.sh --repeat 1 --tests 'xcomposite|linux.capture|x11': 100% of 293 passed in OFF and ON builds.No Xvfb end-to-end case: the harness has no existing xcomposite/linux-capture test, so it would need a full plugin load + window manager; not cheap. There were no prior linux-capture tests to regress. Plugin compile is covered by PR CI (no X headers on the host).
Tiers: Tier 2/3/4 do not apply (C plugin, no Rust port).