Skip to content

fix(computer): the probe's P4 waits for the frame, and a reference driver click lands before the next input - #464

Merged
earakely-scale merged 3 commits into
mainfrom
edgararakelyan/fd-4630-reference-driver-probe-input-checks-p4-click-shows-in-the
Nov 3, 2026
Merged

earakely-scale merged 3 commits into
mainfrom
edgararakelyan/fd-4630-reference-driver-probe-input-checks-p4-click-shows-in-the

Conversation

@earakely-scale

@earakely-scale earakely-scale commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

FD-4630. Two of the conformance probe's input checks flaked on the reference driver: P4 ("a click in frame space hits its cell, and the next frame shows it") and P6 ("a chord selects all, and Backspace clears it"). This PR fixes both. It changes one check and the reference driver.

What changed

  • The probe's P4 frame check waits for the frame. The fixture saves a click to its state before Tk repaints the cell, so one screenshot taken right after the state shows the click can still be white. The check now retakes the screenshot until the cell shows red, within SETTLE_S, just as it already waits for the state. Probe.until takes an optional reader for this. The check is renamed "a click in frame space hits its cell, and a frame shows it".
  • A reference driver click now returns only after the window manager has let it through. A click, the end of a drag, and pointer_up each wait, for up to 5 s, until the pointer state shows the button released. Only after that do they release modifiers and return.

The P6 cause: xfwm4's grab lets keys overtake a click

xfwm4 4.18 holds a passive Button1 grab on client windows. On every click into a window, it takes the press under a synchronous grab, focuses and raises the window, and only then replays the press to the app with XAllowEvents(ReplayPointer). Until it does, the press and the release queued behind it wait in the server. Keys don't wait: they go straight to the focused window. The driver used to return as soon as XTEST had queued the click, so under load the keys that followed reached Tk first.

The harness traced the order of events in the fixture's name field. In every P6 failure, the keys arrived carrying Button1Mask (the server still had the button down), and the click's ButtonPress arrived after them. In one repeat-check failure, the click came about 750 ms late, after a b c d had been typed. That late click landing on the field again made Tk read it as a double click, which selected the word, so the two Backspaces left ''.

The laptop sighting fits the same story. "Hello, Wörld! 東京 AC" means Control+/ selected all and moved the cursor to the end. The late click then cleared the selection and put the cursor between b and C (index 19, where the probe clicks), so Backspace removed only the b.

The two causes the issue suggested don't apply:

  • Focus: at every failure, the X input focus and the top of the stack were the Fixture Desk, and no keys were down.
  • Keymap: / was on its own keycode. The Unicode check's remaps used spare keycodes 222, 230 and 248 and left it alone.

The same grab broke P4's "16 clicks sent at once all land" (9 or 10 of 16). Presses for different cells reached Tk with an earlier click's x_root/y_root, 1–2 ms apart. Tk reads presses within 5 px and 500 ms as a double click, so <Double-Button-1> swallowed their <Button-1>. Since each click now waits for its own release, clicks no longer pile up behind the grab.

Loop counts

Setup:

  • Two fresh agent-environments-admin VMs: c6i.2xlarge (amd64) and c7g.2xlarge (arm64).
  • On each, the shipped desktop computer, the integration tests' one-app notes computer (a Tk boot app), and the chromium test bundle's computer, all composed through gate 3.
  • Each round boots the image fresh, as gate 3 does, then runs the probe at full three times, as the integration test does. That's 17 rounds, or 51 probes, per computer and arch.
  • "Contended" means eight busy loops on the box's eight vCPUs, alongside the three looping computers.
  • The fixture was instrumented only in the harness, not in this PR.

Failed probes out of 51:

Computer Arch main, idle main, contended this PR, contended
desktop amd64 0 2 (P6 repeat, P6 tabs and newlines) 0
desktop arm64 0 4 (P6 repeat ×3, P4 16 clicks) 0
notes amd64 0 2 (P6 repeat ×2) 0
notes arm64 1 (P4 16 clicks) 2 (P6 repeat, P4 16 clicks) 0
chromium amd64 0 2 (P6 repeat ×2) 0
chromium arm64 0 1 (P4 16 clicks) 0
Total 1 / 306 13 / 306 0 / 306
  • First probes: all 14 failures were the first probe after a fresh boot, which is the probe gate 3 runs. Contended first probes failed 13 of 102 times on main and 0 of 102 with this PR. Later probes on the same boot never failed (0 of 408).
  • The chord check itself: it never failed in the loop. Even so, its keys overtook its click in 17 of 102 contended first probes on main, and in 0 of 102 with this PR. It fails only when the late click lands between Control+/ and Backspace, as it did on the laptop.
  • P4's frame check never failed in the 612 runs on main. The retake fixes the CI sighting by construction, and the unit test below covers it.
  • Probe time: unchanged, with a median of 12.5–17 s per probe depending on the box and the load.

Other flakes from the Nov 3 Mac test

  • P4 on a Chromium computer and on bench-sentinel: the Mac notes don't say which P4 check failed. On Chromium, the loop showed only the 16-clicks failure (arm64, contended), which this PR fixes. bench-sentinel uses the same driver and window manager. I didn't run it.
  • Chromium's data/get file race: that's a separate path, the known BrowserMetrics race in website_browser_test. Left alone.

Gate 3: rerun a failed input check before failing the build?

This is your decision; it isn't implemented here. The options:

  1. Keep it strict (today's behaviour). One probe, and any failed check marks the build failed.
    • Every flake measured here had a real cause, and a rerun would have hidden it. The P6 one was a driver bug that any client clicking and then typing within milliseconds would hit.
    • A one-off failure means running agent-env env build again.
  2. Rerun the probe once on a fresh boot when only P3–P7 fail, and keep the first report in the probe record, for example a retried entry with the failed checks.
    • A one-off doesn't fail a put.
    • Gate 3 takes about 20–30 s longer when it reruns.
    • Since failures clustered on the first probe after boot, a rerun nearly always passes, so it also hides regressions unless the recorded retry is surfaced.
  3. Rerun only the failed checks. The P6 checks build on each other's fixture state, so each would need restaging. That's more code than the other two.

Recommendation: option 1, for now. Measured on main, failures were 1 in 102 first probes on an idle box and 13 in 102 under contention. With this PR they're 0 in 102 under the same contention. A rerun at this point would mainly mask regressions like this one. If flakes come back on real hosts, adopt option 2 with the first report kept.

Testing

All on two agent-environments-admin VMs (about $0.90, both terminated):

  • Unit: make unit-test at e25a1b2: 12,635 passed, 7 skipped and 2 failed. The two failures need unzip, which the VM lacks (test_chromium_app.py::…unpacks_the_archive… and run_docker_container_test.py::…context_zip…); both fail the same way on main there. CI's unit job passed.
  • New tests, which fail on main and pass here:
    • A StaleFrame fake driver, whose first capture after a click is from before the click, passes at full.
    • A fake X whose window manager holds the click for three pointer queries. The click, the drag's release and pointer_up each return only after it replays, and the click's Shift is released after that.
  • Added for Greptile's review (c28a9cc): a StaleFrame whose frames never show the click fails P4, and the report names the last pixel. test_computer_conformance.py: 24 passed.
  • Integration (amd64): tst/integration/computer/computer_env_test.py, computer_app_test.py, desktop_example_test.py, chromium_app_test.py and website_browser_test.py: 21 passed, 1 skipped (model_endpoint_configured).
  • Gate 3: passed at full for all six composed images on both arches, before and after the change.

🤖 Generated with Claude Code

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with no outstanding findings.

Summary

The PR waits for P4's frame to show the click and waits for button release before the reference driver returns.

  • The P4 probe waits until a clicked cell appears in a frame.
  • Reference clicks wait for the button release to clear or time out before returning.

Reviews (2) · Last reviewed commit: "test(computer): frames that never show a..." · Reviewed by Greptile

earakely-scale and others added 2 commits November 2, 2026 22:57
The fixture saves a click to its state before Tk repaints the cell, so the one screenshot P4 took after the state
showed the click could still be white. It now retakes the screenshot until the cell shows, within SETTLE_S, as it
already waits for the state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er has replayed it

xfwm4 holds a click on a window under its passive Button1 grab until it replays it to the app, while key events reach
the focused app at once. Under load the replay came hundreds of milliseconds late, so keys sent right after a click
reached the app before it (P6's chord and repeat checks failed) and the next clicks' presses carried an earlier click's
position, which Tk read as double clicks (P4's 16 clicks). Input that lets go of a button now waits, up to 5 s, until
the pointer state shows the button up, which happens only once the window manager has let the click through.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale
earakely-scale requested a review from a team as a code owner November 3, 2026 07:52
…4 with the last pixel

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@earakely-scale
earakely-scale merged commit cebd9e3 into main Nov 3, 2026
26 checks passed
@earakely-scale
earakely-scale deleted the edgararakelyan/fd-4630-reference-driver-probe-input-checks-p4-click-shows-in-the branch November 3, 2026 18:41
earakely-scale added a commit that referenced this pull request Nov 3, 2026
…nce driver's click lands first (#464)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant