Files
feuerwerk/tools/remote/gm-browser.ps1
T
rootandClaude Opus 5 32a40ee34b Run the check browser on the GPU instead of rasterising in software
The harness forced software WebGL (--disable-gpu --use-gl=swiftshader) on every host.
Measured here on an idle editor page over 20 s: that costs 373% of a core at 8 fps,
while the Intel HD 630 via ANGLE/Vulkan costs 69% at 56 fps. The full suite now runs
in ~124 s. Note the app is not rendering 60 fps as previously assumed - in software
it only reaches 8, and a single frame costs more than any throttle interval would save,
which is why capping the framerate had measured no effect.

--use-angle=gl and --use-gl=egl look cheaper still but get no WebGL context at all,
so the app never renders. They are not usable and are named in the comment as such.

There is deliberately no software fallback: a host without a usable GPU should fail
loudly rather than drag the machine to a standstill. None of the 267 checks reads the
rendered image anyway - they read window.__gm.locate() and the debug hook, and the
screenshots assert nothing - but Pixi needs WebGL2 to run at all.

The browser launch moves out of harness.mjs into tools/lib/browser.mjs, which also
supports GM_REMOTE=user@host via an SSH-forwarded CDP port. That path is unfinished:
the tunnel degraded until the suite crawled at ~25 s per check, and forcing software
WebGL on a desktop with a real card brought it to its knees. README says so plainly
rather than advertising it.

Also: the jump-run HUD check asserted a fixed "Coins 1/10", which fails on a faster
host where the same walk sweeps up two coins. It now asserts the HUD against the count
the run actually reached - the real guarantee is that HUD and state agree.

Verified: npm run check green (404 tests), 267 e2e ALL PASSED and 24 jump-run checks
ALL PASSED against the GPU flags. The fallback removal leaves the flag set on this host
identical (same flags, different order), so it was not re-run.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-09 08:46:16 +02:00

44 lines
2.1 KiB
PowerShell

# Launches a headless browser with the CDP port open and ties its life to this SSH session:
# stdin closing (the caller went away, however violently) kills the whole process tree. Without
# that leash the browser survives a dropped connection - measured: 8 orphaned chrome.exe.
param([int]$Port = 9333, [string]$Size = "1280,800")
$ErrorActionPreference = 'Stop'
$candidates = @(
"C:\Program Files\Google\Chrome\Application\chrome.exe",
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe",
"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"
)
$exe = $candidates | Where-Object { Test-Path $_ } | Select-Object -First 1
if (-not $exe) { [Console]::Error.WriteLine("no chrome or edge found"); exit 2 }
$udd = Join-Path $env:TEMP "gm-e2e-$Port"
Remove-Item -Recurse -Force $udd -ErrorAction SilentlyContinue
# No --disable-gpu here: forcing software WebGL on a desktop with a real card rasterises every
# frame on the CPU and made the host unusable. Let the machine use the card it has.
$flags = @(
'--headless', '--ignore-gpu-blocklist', '--renderer-process-limit=1',
"--remote-debugging-port=$Port", "--user-data-dir=`"$udd`"", "--window-size=$Size",
'--hide-scrollbars', '--disable-background-networking', '--disable-sync',
'--disable-extensions', '--no-first-run', '--mute-audio', '--no-default-browser-check',
'about:blank'
)
$proc = Start-Process -FilePath $exe -ArgumentList $flags -PassThru -NoNewWindow
[Console]::Error.WriteLine("gm-browser: $exe pid=$($proc.Id) port=$Port")
# Either the browser dies on its own, or our caller does. Both must end this script.
while (-not $proc.HasExited) {
if ([Console]::In.ReadLine() -eq $null) { break }
}
if ($proc.HasExited) {
[Console]::Error.WriteLine("gm-browser: browser exited on its own with code $($proc.ExitCode)")
} else {
# taskkill and tasklist filters are denied to this account; Stop-Process is not. Killing by name
# is safe here because the account exists only to run these tests.
Get-Process chrome, msedge -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
[Console]::Error.WriteLine("gm-browser: stdin closed, killed the browser")
}