Skip to content

test(cmocka): wait for a painted program frame in the screenshot sRGB tests (#2785) - #2787

Merged
zackees merged 1 commit into
masterfrom
fix/2785-screenshot-program-wait
Oct 28, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/2785-screenshot-program-wait

Conversation

@zackees

@zackees zackees commented Oct 28, 2026

Copy link
Copy Markdown
Member

Fixes #2785. Build 🧱 / Qt Frontend Linux 🐧 was red on master push run
40683133291
(head 3f29f24e2): test_frontend_screenshot_srgb and
test_ws_screenshot_srgb both failed only their first case,
nv12_orange_is_unchanged, with a correct screenshot and a black program
pixel:

NV12 orange: want (255, 96, 0), screenshot (255, 96, 1, 255), program (0, 0, 0)

Every later case in both binaries reported the right program pixel.

RED

The RED evidence is that master push run's log; there is no code-level RED
commit because the defect is in the test's wait, not in a product behaviour
that a new test could pin:

const uint64_t start = frames_seen();
for (int i = 0; i < 100 && frames_seen() < start + 8; i++) {
        f.frame.timestamp = os_gettime_ns();
        obs_source_output_video(source, &f.frame);
        os_sleep_ms(20);
}

frames_seen() counts obs_add_raw_video_callback() deliveries. Those start as
soon as obs_set_output_source() is set and are black until the scene has
drawn once (llvmpipe, 2 physical cores, cold shader cache on that runner), and
the bound is only 100 * 20 ms = 2 s, so the loop exits on black pre-render
frames. That is why only the first case of each binary fails: the shaders are
warm afterwards and the very same loop then sees painted frames. The loop also
has no failure path when the frames never arrive — it silently proceeds with
the initialised {0, 0, 0}.

GREEN

wait_for_painted_program() pumps one frame per 20 ms until a raw frame has
been delivered and the program pixel is no longer black, bounded at 10 s;
on timeout the case fails with the format, the elapsed bound and the raw frame
count, so the next occurrence says which half went wrong instead of reporting a
black-pixel mismatch. None of these cases expects black, so "not black" is
exactly what says the scene has drawn. No product code changes.

Verified from this checkout's Tier 2 Linux build volume (both targets are built
there, OS_LINUX + Qt6 + libobs-opengl, ENABLE_FRONTEND=OFF does not
gate them):

$ ninja test_frontend_screenshot_srgb test_ws_screenshot_srgb
[9/14] Linking CXX executable test/cmocka/test_frontend_screenshot_srgb
[11/14] Linking CXX executable test/cmocka/test_ws_screenshot_srgb

$ cd rundir/RelWithDebInfo && xvfb-run -a /build/tree/test/cmocka/test_frontend_screenshot_srgb
NV12 orange: want (255, 96, 0), screenshot (255, 96, 1, 255), program (255, 96, 1)
[  PASSED  ] 7 test(s).
$ cd rundir/RelWithDebInfo && xvfb-run -a /build/tree/test/cmocka/test_ws_screenshot_srgb
NV12 orange: want (255, 96, 0), screenshot (255, 96, 1, 255), program (255, 96, 1)
[  PASSED  ] 6 test(s).

clang-format 22.1.3 --dry-run --Werror clean on both files (./lint's
C/C++ lane). No local gate stamp: this touches only test/cmocka/ C++ tests,
no Rust, CMake or build input, and the binaries above were built and run
directly in the Tier 2 volume.

What this does not do

  • It does not reproduce the flake locally. On this 16-core host the old code
    also passes (MESA_SHADER_CACHE_DISABLE=true, --cpus=1, two runs each), so
    the only reproduction is the CI log above; what the fix guarantees is that a
    program that has not painted can no longer be sampled, bounded so a real
    "never renders" regression still fails.
  • It does not touch #2763's frame-timing extraction; that commit is in the
    failing run's history, but the black-pixel-only-on-the-first-case pattern in
    both binaries points at render warm-up, not at tick timing. If a reviewer
    reads it the other way, the new timeout message will say so on the next red.

Refs the master red on 3f29f24e2; no docs/features.md line (no user-visible
change).

… tests

Both screenshot sRGB tests waited for eight raw-video deliveries and then
sampled the program's centre pixel. Those deliveries begin as soon as the
output source is set and are black until the scene has drawn once, so on a
cold runner (llvmpipe still compiling the scene's shaders) the loop stopped
on a black pre-render frame and the case failed with `program (0, 0, 0)`
while the screenshot itself was correct - master push run 40683133291, first
case of both binaries only.

Wait for a raw frame whose program pixel is not black instead (none of the
cases expects black), bounded at 10 s, and fail with the format, bound and
raw frame count so a program that never renders says so.

@zackees zackees left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coordinator review: looks right, and the mechanism is sound.

Read against origin/master (ecf72dd5f). Verified from the diff and both files at eab5b5689:

  • frames_seen() returns program_frames under program_mutex in both binaries, so passing it as start and comparing program_frames > start inside wait_for_painted_program() is a genuine "a frame arrived after this call began", not a comparison between two counters. (The PR body's "counts obs_add_raw_video_callback() deliveries" is accurate but a step removed: raw_video() is what increments program_frames.)
  • The non-black gate is the correct predicate: none of the 13 cases (7 frontend + 6 ws) expects a black program pixel, so "r,g,b not all zero" is exactly "the scene has drawn". The frames > start half keeps it from passing on a stale pixel from the previous case.
  • The failure path is bounded at 10 s and reports format, bound and raw-frame count, so a genuine "never renders" regression fails with a reason instead of a black-pixel mismatch. fail_msg does not abort, so on timeout capture() continues and the case will usually also print its pixel mismatch — two messages on one failure, which is harmless and arguably useful.
  • No product code, test/cmocka/ only: no docs/features.md line is correct under AGENTS.md (no user-visible change), and no local gate stamp is needed for this shape.
  • clang-format --dry-run --Werror clean on both files here (21.1.8; the PR says 22.1.3 — both pass, so no version drift in the formatting of the added hunks).
  • CI evidence: Build 🧱 / Qt Frontend Linux 🐧 — the lane that was red on master — is green on this head, which is the authoritative run for these two binaries. Rust Tier 2 windows/macos were still in progress at review time; the coordinator will queue once all checks complete.

Nothing to fix. Leaving the merge to the queue once the two remaining Tier 2 lanes finish.

@zackees
zackees added this pull request to the merge queue Oct 28, 2026
@zackees

zackees commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

Handed off to the coordinator.

Green: CI Gate ✅ on 40687671781; the Qt Frontend Linux 🐧 lane — the one that was red on master — passed in 4m14s with the fixed tests, and both binaries pass locally in the Tier 2 volume (7/7 and 6/6).

No local gate stamp: this touches only two test/cmocka/*.cpp tests (no Rust, CMake or build input), so the stamp would attest lanes this change cannot affect.

Merged via the queue into master with commit c2c56cc Oct 28, 2026
39 checks passed
@zackees
zackees deleted the fix/2785-screenshot-program-wait branch October 28, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug: Screenshot sRGB tests sample a black program frame on a cold runner (Qt Frontend Linux red on master)

1 participant