tools/visreg: visual regression harness for xframe-demo (547 widgets)

One command re-renders every widget exactly as the docs sweep did
(prebuilt target/debug/examples/<Name> under Xvfb 1280x1024x24,
captured with import -window, settled until two frames agree) and
diffs it against tools/visreg/golden/ with ImageMagick
compare -metric RMSE (default threshold 0.5%), writing a per-widget
report.csv/report.md/summary.txt to tools/visreg/report/.

Goldens are the Dec 2, 2026 docs-sweep screenshots from
/opt/lightgui-docs/rust_shots/. GtkCalendar golden was a mid-draw
capture artifact (fill only, no border/text) and is refreshed from a
settled render, verified pixel-identical (RMSE 0) to the docs pilot
screenshot. GtkInvisible is skipped by design (draws nothing).
This commit is contained in:
cnmcdee committed 2026-12-02 09:37:47 +00:00
1 parent b42ab73b80
commit 414cfe2a54
550 files changed
+378

No files matched your search

+1
View File
@@ -0,0 +1 @@
report/
+91
View File
@@ -0,0 +1,91 @@
# Visual regression harness (`tools/visreg/`)
Re-renders every `xframe-demo` widget and diffs it against its golden
screenshot, so a drawing regression shows up as a failing widget instead
of a surprise on a docs page.
## Run
```sh
tools/visreg/run.sh # full sweep: all 547 widgets
tools/visreg/run.sh --widgets "GtkButton GtkLabel" # subset
tools/visreg/run.sh --threshold 1.0 # looser threshold
```
Exit code is 0 when every compared widget passes (or is skipped), 1 when
any widget fails. A report is written either way to `tools/visreg/report/`:
- `report.csv` — one row per widget: `name,status,rmse_pct,rmse_raw,notes`
- `report.md` — summary + failure table
- `summary.txt` — one-line counts
- `diffs/` — ImageMagick diff images, failures only
`report/` is git-ignored; the harness, goldens and this README are
committed.
## How it renders
The same path the docs sweep used (Dec 2, 2026, hot_chicago):
1. Runs the prebuilt `target/debug/examples/<WidgetName>` binary (built
once by `cargo build -p xframe-demo --examples`; the harness rebuilds
only if a binary is missing, or always with `--rebuild`).
2. Under Xvfb (`1280x1024x24`, no window manager), the demo opens its
800x600 window at 100,100 and draws the widget.
3. The window is found by title (`<Name> - XFrame demo`) with `xdotool`
and captured with ImageMagick `import -window <wid>` — with no WM
there are no decorations, so the capture is exactly the 800x600
client area, matching the goldens. The capture is *settled*: frames
are taken until two consecutive screenshots are pixel-identical, so
a shot can never catch the X server mid-draw (the docs sweep's
GtkCalendar golden did exactly that — fill drawn, border/text not
yet — and the harness refuses to repeat the mistake).
## How it compares
`compare -metric RMSE golden new diff.png`. The normalised RMSE (the
parenthesised value, 0–1) × 100 is the reported RMSE %. A widget passes
when RMSE % ≤ threshold (default **0.5%**).
The threshold is deliberately not zero: screenshots can differ by a few
pixels from font rendering / anti-aliasing between runs, and a
zero-threshold harness would cry wolf. 0.5% of an 800x600 window is
~2,400 fully-different pixels — far above the handful of pixels of AA
wobble a clean tree produces (a clean-tree run measures 0.0000% on the
overwhelming majority of widgets), and far below what any real drawing
regression produces (a missing border, wrong fill or shifted label is
typically several percent). If a clean tree ever fails, the threshold —
not the widget — is the suspect; re-tune it from a calibration run
(`--widgets` a sample across families, inspect the RMSE distribution)
before touching widget code.
## Goldens
`golden/` holds the 547 docs-sweep screenshots from
`/opt/lightgui-docs/rust_shots/` (Dec 2, 2026) — the same images on the
rustdoc widget pages. They are the baseline: a widget that renders
identically to its docs screenshot passes.
To accept an intentional rendering change, review the failure diffs in
`report/diffs/` first, then:
```sh
tools/visreg/run.sh --widgets "<changed widgets>" --keep-shots --update-goldens
git diff --stat tools/visreg/golden/ # confirm only intended goldens moved
```
## Known skips
- **GtkInvisible** — skipped by design. It draws nothing (its golden is
a blank 800x600 window); there is nothing to compare.
## Known-baseline notes
- **GtkCalendar golden refreshed Dec 2, 2026.** The docs-sweep golden
was a mid-draw capture: grey fill only, no border and no `Calendar`
label (RMSE 3.9246% vs a correct render). The widget/drawing code is
unchanged since Nov 30, and the docs *pilot* screenshot of the same
widget (taken 06:00 UTC, before the sweep) is pixel-identical
(RMSE 0) to the current render — so the golden, not the widget, was
wrong. Refreshed from a settled harness capture; the stale file is
not kept.
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 732 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 873 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 962 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 669 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 720 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 890 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Loaded 100 of 550 files, more files were not shown because too many files have changed in this diff. Show more