Skip to content

linux-capture: XComposite video_tick does blocking X round trips per frame under the graphics lock #1356

Closed

Description

@zackees

Part of #1273 (found by the #1285 capture-plugin audit). B, graphics thread.

plugins/linux-capture/xcomposite-input.c.h:577-597: XComposite window capture's video_tick takes obs_enter_graphics() and then calls xcomp_window_exists() once or twice per frame. That is a blocking xcb_get_window_attributes request and reply.

obs_enter_graphics();
pthread_mutex_lock(&s->lock);
...
bool window_lost = !xcomp_window_exists(xcomp_conn, s->win) || !s->gltex;

Failure scenario: a busy, stalled or remote X server holds up video_tick, and every other graphics user with it, for one or two round trips per frame per XComposite source. Not a spin, but latency on the render path.

Fix:

  • Track the window's existence from X events already being watched (DestroyNotify, UnmapNotify and MapNotify through the existing watcher) instead of asking every frame.
  • Or at least do the check outside obs_enter_graphics() and the source lock, and at most once per frame.

Test: a counter around the existence check in a fake-connection test (or xcb call counting under Xvfb): with a stable window, round trips per second are about 0, not about the frame rate.

Activity

  1. zackees commented on Oct 18, 2026

    @zackees
    MemberAuthor

    Claiming. Plan: track whether the captured window exists from the X events the watcher already receives (DestroyNotify / UnmapNotify / MapNotify), instead of a blocking xcb_get_window_attributes round trip 1-2 times per frame under obs_enter_graphics(). Keep a cheap, rate-limited check as a safety net. Builds on #1366's search backoff. RED: a pure helper test counts existence round trips per simulated second (about the frame rate today, about 0 with a stable window after the fix).

  2. added
    claimedAn agent or person has claimed this; check the claim comment before starting
    on Oct 18, 2026
  3. removed
    claimedAn agent or person has claimed this; check the claim comment before starting
    on Oct 20, 2026
  4. zackees commented on Oct 23, 2026

    @zackees
    MemberAuthor

    Fixed by #1377 (merged). That PR used Refs, so the issue stayed open, but its body lists no remaining work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions