Files
reims-vgpu/scripts/modal-button-probe
Anees Iqbal 0a5b9b14ba 🐛 Every probe read the desktop size from a report macOS 12 does not produce
Component: scripts/ — the guest-facing probes (wallpaper, modal-button,
window-drag) and the new scripts/lib/guest-display.sh they share.

`system_profiler SPDisplaysDataType | grep Resolution:` was how three probes
learned the desktop's size. On the macos-12 rail that report names the GPU and
**no display at all** — no `Displays:` section, no `Resolution:` line — so all
three exited 2 before doing anything, and `visual-gate --quick` reported
SETUP-FAILED with 0/3 probes green on a rail whose desktop, Dock and menu bar
were up and rendering. The same call has been observed hanging indefinitely on
macos-11, which an unattended harness cannot tell from a wedged boot.

`guest_display_size` asks with `screencapture` plus `sips` instead. Both ship
with every macOS, neither needs root, and the answer is the stronger form of
the question a two-observation probe is asking: not what the guest's
configuration claims the display is, but how many pixels its compositor just
produced. Verified on the macos-12 rail — 1920x1080, where system_profiler
returned nothing — and the wallpaper probe now reaches its trials there.

Second failure on the same rail, same cause class: `osascript -e 'tell
application "System Events" ...'` over ssh hangs forever when the session has
not been granted Automation access, because the consent prompt is raised on the
guest's own desktop and nobody answers it. Every System Events call in every
probe hung there. `guest_osa` bounds them host-side at 15 s (GUEST_OSA_TIMEOUT),
which is the difference between a probe that reports "this rail cannot be
scripted" and one that stalls a sweep. The bound does not kill the remote
osascript; it only stops us waiting on it.

Tests: no Rust change. `bash -n` clean on all four files. Verified live against
the macos-12 rail: the size read returns 1920x1080 where the old one returned
nothing.

Not verified: the macos-11, 14, 15 and 26 rails, and the arm64 pathway. The
Automation-consent gap on macos-12 is a guest provisioning matter and is not
fixed here — the probes now report it quickly instead of hanging on it.
2026-08-09 07:55:04 +03:00
..

modal-button-probe

Asks whether a guest modal's buttons actually reach the screen, and — when they do not — which side dropped them.

Why it exists

The bug it was written for is "the logout window sometimes shows no sleep, shutdown and restart buttons, more likely when dark mode is on". That report is a screenshot observation, and a screenshot on its own cannot say whether the guest declined to draw the buttons or whether this device lost them on the way to the screen. Those are different bugs with different owners, and no amount of staring at the image separates them.

Two independent observations of the same frame do:

  • Intent — the guest's accessibility API, asked directly what buttons loginwindow's window has and at what rectangles. This reads the guest's own view hierarchy, upstream of anything this project touches.
  • Result — the host-side capture of the QEMU window, measured at exactly those rectangles.

A button the guest declares and the frame does not show is a compositing loss here. A button the guest never declares is a guest-side absence and not ours. The probe prints which, per button, per trial.

Usage

scripts/modal-button-probe/modal-button-probe.sh [-n TRIALS] [--appearance dark|light|alternate] [--keep DIR]

Needs a running guest reachable as macos-vm over SSH and a host QEMU window the KDE screenshot script can capture. --keep DIR retains the PNG and the accessibility dump of every trial, which is what you want the moment a trial fails.

Exit codes: 0 every declared button was drawn, 1 at least one trial found a declared-but-undrawn button, 2 setup failure (no guest, no window, the modal never appeared).

How the verdict is reached

Each button's rectangle is converted from guest points to capture pixels using the scale read off the capture and the guest's reported display size — neither is assumed, because the capture is downscaled to fit 720p and a guest at another resolution would otherwise shift every rectangle silently.

The rectangle's greyscale standard deviation is then compared against a background reference taken from the same frame: the modal is tiled with patches and the flattest one is used. The dialog is mostly its own fill, so the flattest patch is background — whatever the appearance and whatever the layout, and without naming a corner that some dialog happens to put an icon in. A drawn button has an edge and a label and varies more; a missing one leaves the fill.

There is no tuned threshold. Measured on the guest's logout modal, buttons read sigma 0.055–0.104 against a background of 0.0008–0.0012 in both dark and light — 45x to 130x separation — so a bare > and any factor up to about 40 decide the same cases.

What it does not cover

It summons the log-out modal (Log Out / Cancel), because that one can be raised from a script and dismissed again without acting on it. The dialog named in the bug report is the Control-Power one (Sleep / Restart / Shut Down / Cancel), which has no scriptable trigger that does not risk executing the action. Both are windows of the same loginwindow process and go through the same compositing path, so this is a proxy for that dialog and not the dialog itself. Say "the logout modal" when reporting a result from it.

It also cannot see a button that is drawn in the wrong place: it only asks whether something was drawn where the guest said the button is. A button rendered 200 px away would read as MISSING at its declared rectangle, which is the correct verdict for "the user cannot click it" but does not describe what happened. Keep the frame (--keep) and look.