Component: host-side probe harness (`vm/guest-authorize.sh`, `scripts/lib/`,
`scripts/window-drag-probe/`). No device or Rust change; no pathway behaviour
changes.
Driving a guest's GUI needed four separate things that only the macos-13 rail
had, and each one failed in a way that read as a defect somewhere else. On
macos-11 the combined symptom was `could not read Safari's window frame (pos ''
size '')`, which reads as a compositor that produces no windows — on a rail
whose desktop was on screen at the time.
1. **Apple Events consent has a panel and nobody was answering it.** The first
`osascript ... "System Events"` from an ssh session raises a modal on the
guest's own screen; until it is answered the call never returns. Nothing on
the host can see it. `vm/guest-authorize.sh` now runs a consent probe, and
*only if that probe is seen to hang* presses Return over QMP's usb-kbd — the
panel's default button is Allow. The keystroke is never sent blind, because a
Return at a live desktop is not free. Self-verifying: the same call is
retried and has to answer. `--no-automation` opts out.
2. **TCC scopes Apple Events per (client, target) pair**, so consenting System
Events says nothing about Safari. `guest_apple_events_consent` in
`scripts/lib/guest-display.sh` is the one implementation, called per app.
3. **The probes drove windows through System Events, which needs assistive
access — and that has no panel to answer.** It is granted by hand in System
Preferences, and macos-13 is the only rail where someone did. Everywhere else
`System Events` answers `-25211` and the probe reports an app with no
windows. Both the frame reads and `reposition.applescript` now go through the
target application's own Standard Suite (`bounds of front window`), which
needs only consent 1–2. `bounds` is {l,t,r,b}, so the loop carries the window
size across steps to move without resizing.
4. **Two guest-side dependencies that are not part of macOS.** `open -a Safari
about:blank` fails on macOS 11 — Big Sur's `open` resolves a bare argument as
a path first, so Safari never launched; the probe now opens a local blank
file, which also keeps the network out of a compositing measurement. And the
reposition run was timed by a guest-side `python3`, which is a
Command-Line-Tools stub that raises an install dialog on a rail without them
and does not exist at all from 12.3. Timing moved to the host, so the guest
step is `osascript` and nothing else; the ssh round trip is counted into
elapsed, which understates the achieved rate and never overstates it.
Also: an unreadable frame now names which of the three causes it was, instead of
printing the empty string it got.
Verified on the live macos-11 rail (macOS 11.7.11, x86 `reims-vgpu-pci`, KVM,
discrete NVIDIA host), snapshot `current`. First driven measurement this rail has
ever had — `window-drag-probe --seconds 25 --app Safari` now completes:
posted 1202 steps in 24.5 s = 49.1 Hz achieved
present_hz med 46.65 max 50.00 offered_hz med 46.65
window blocked 0, window wait_us 0 draw_us/draw med 137
module_rejected 0 across the whole boot
The device tracked the stressor: 46.7 Hz presented against a 49.1 Hz motion, so
these counters are bounded by the Apple Events round trip and are not this
device's ceiling. The probe says so itself.
Not verified: `--motion drag` still needs clang on the guest and Accessibility
trust, and neither is available on this rail — that path is unchanged and still
reports its own build failure. Nothing here was run on arm64, on macos-12/14/15/26,
or with `REIMS_GUEST_IMPORT=off`; no Rust code is touched so no clippy or
feature-matrix arm is affected.
Co-Authored-By: Claude <noreply@anthropic.com>
68 lines
3.1 KiB
AppleScript
68 lines
3.1 KiB
AppleScript
-- reposition.applescript — move a window along a path as fast as Apple Events
|
|
-- allow, for a fixed duration.
|
|
--
|
|
-- This is the fallback motion, and it is not a pointer drag. A real drag needs
|
|
-- CGEventPost (see drag.c), whose events this guest silently discards because
|
|
-- the posting process is not trusted for Accessibility and TCC.db cannot be
|
|
-- written here: there is no passwordless sudo and SIP's Filesystem Protections
|
|
-- are on.
|
|
--
|
|
-- It drives the target application through its **own** Standard Suite rather
|
|
-- than through System Events' accessibility objects. That is not a style
|
|
-- choice. The `System Events` route needs assistive access, which TCC grants
|
|
-- only by hand in System Preferences and which exactly one rail of six has;
|
|
-- every other rail answers `osascript is not allowed assistive access (-25211)`
|
|
-- and the probe reads that as an app with no windows. An application's own
|
|
-- `bounds of front window` needs only Apple Events consent, and that panel has
|
|
-- a default button the harness can press over QMP.
|
|
--
|
|
-- What that costs is stated rather than glossed: the window server sees a
|
|
-- sequence of window moves instead of a pointer held across a title bar, so any
|
|
-- work specific to a drag session is missing. What it keeps is the part the
|
|
-- device sees — a large window changing position at high rate, and everything
|
|
-- behind it recomposited.
|
|
--
|
|
-- Runs for a duration rather than a step count, and cannot be paced: each
|
|
-- `set bounds` is a synchronous round trip, so the rate is whatever that costs
|
|
-- and `--hz` has no meaning in this mode. Taking a step count instead was a real
|
|
-- defect — asking for 15 s at 12 Hz ran 180 steps flat out and finished in
|
|
-- 1.9 s, so the run measured a third of the intended window and reported it as
|
|
-- if it were the whole one.
|
|
--
|
|
-- `bounds` is {left, top, right, bottom}, so moving without resizing means
|
|
-- carrying the width and height across every step. They are read once up front
|
|
-- rather than per step, which keeps the loop to one round trip.
|
|
--
|
|
-- Returns the number of steps performed; the caller times the run, because
|
|
-- AppleScript's `current date` has one-second resolution and cannot.
|
|
on run argv
|
|
set appName to item 1 of argv
|
|
set x0 to (item 2 of argv) as integer
|
|
set y0 to (item 3 of argv) as integer
|
|
set secs to (item 4 of argv) as integer
|
|
set ampX to (item 5 of argv) as integer
|
|
set ampY to (item 6 of argv) as integer
|
|
|
|
set done to 0
|
|
tell application appName
|
|
set b to bounds of front window
|
|
set w to (item 3 of b) - (item 1 of b)
|
|
set h to (item 4 of b) - (item 2 of b)
|
|
set t0 to current date
|
|
repeat with i from 1 to 1000000
|
|
if ((current date) - t0) ≥ secs then exit repeat
|
|
-- Two incommensurate periods, so the path is not a straight slide,
|
|
-- which is the one motion a compositor may coalesce. Integer
|
|
-- arithmetic only: AppleScript has no cheap sine and the point is
|
|
-- the motion, not its exact shape.
|
|
set dx to ((i * 7) mod (2 * ampX)) - ampX
|
|
set dy to ((i * 11) mod (2 * ampY)) - ampY
|
|
set nx to x0 + dx
|
|
set ny to y0 + dy
|
|
set bounds of front window to {nx, ny, nx + w, ny + h}
|
|
set done to done + 1
|
|
end repeat
|
|
end tell
|
|
return done
|
|
end run
|