Files
reims-vgpu/scripts/browser-probe/chrome-gpu-status.sh
T
Anees Iqbal 1fd9e88383 ✨ A browser probe that can read the browser's own GPU verdict
The browser-facing goals (Chrome/Firefox GPU acceleration, WebGL, WebGPU,
in-page frame rate) are scored on facts only the browser can report, and
nothing in the tree could ask it. A host-window screenshot cannot say why
`chrome://gpu` disabled a feature, and `chrome://gpu` renders its report
inside a shadow root, so even a screenshot of it is not text.

`scripts/browser-probe/cdp.py` speaks the Chrome DevTools Protocol over a
hand-rolled RFC 6455 client. Neither the Linux host nor the macOS guest has
`websockets` or `websocket-client`, and installing one into the guest would
change the snapshot under measurement, so the ~80 lines of client framing are
written out directly. Chrome exposes CDP natively and Firefox 129+ exposes it
behind `remote.active-protocols=2`, so one client covers both.

`chrome_gpu_report.py` prints the Graphics Feature Status, driver identity and
Problems Detected blocks as plain lines. It is a file rather than a heredoc
piped through ssh because the shadow-DOM walk needs `\n` inside a JS string
literal and a double-quoted ssh command eats one level of backslash, which
fails as a syntax error pointing at an unrelated line.

`chrome-gpu-status.sh` gives every run a fresh `--user-data-dir`. Chrome latches
"GPU access is disabled due to frequent crashes" into the profile, so a reused
profile reports some earlier boot's verdict rather than the build under test —
that is not a hypothetical, it is what the first reading here did.

Tooling only; no crate code touched, so no test or clippy arm is affected.
2026-08-01 21:59:24 +03:00

48 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# scripts/browser-probe/chrome-gpu-status.sh — ask Chrome in the guest what it
# thinks of the GPU, in text, with a profile that has no history.
#
# Chrome latches "GPU access is disabled due to frequent crashes" into the user
# data dir, so a reused profile reports the verdict of some earlier boot rather
# than of the build under test. Every run here gets a fresh --user-data-dir for
# that reason; the cost is one cold GPU-process start per run.
#
# Extra Chrome flags are passed through, which is how the ANGLE backend is
# varied (--use-angle=metal|gl|swiftshader) without editing this script.
#
# scripts/browser-probe/chrome-gpu-status.sh [--label NAME] [-- <chrome flags>]
#
# Prints the Graphics Feature Status block, the GL/driver identity lines and the
# Problems Detected block. Requires the guest reachable as ssh host `macos-vm`.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
GUEST="${GUEST:-macos-vm}"
PORT="${CDP_PORT:-9222}"
LABEL="run"
while [ "$#" -gt 0 ]; do
case "$1" in
--label) LABEL="$2"; shift 2 ;;
--) shift; break ;;
*) echo "unknown arg: $1" >&2; exit 64 ;;
esac
done
EXTRA=("$@")
CHROME='/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
PROFILE="/tmp/chrome-probe-$LABEL"
scp -q "$SCRIPT_DIR/cdp.py" "$SCRIPT_DIR/chrome_gpu_report.py" "$GUEST:/tmp/"
# `--no-first-run` alone still lets the updater and the default-browser prompt
# start; both add minutes to a cold profile and neither is under test.
ssh "$GUEST" "pkill -f 'Google Chrome' >/dev/null 2>&1; sleep 2; rm -rf '$PROFILE'
nohup '$CHROME' --user-data-dir='$PROFILE' --no-first-run --no-default-browser-check \
--disable-features=ChromeWhatsNewUI --remote-debugging-port=$PORT \
${EXTRA[*]:-} about:blank >/tmp/chrome-$LABEL.out 2>&1 &
sleep 12"
ssh "$GUEST" "python3 /tmp/chrome_gpu_report.py"