547 WIDGETS, ZERO PIXELS OUT OF PLACE?! LightGUI's Visual Regression Harness Re-Renders Every Widget and Diffs It Against the Goldens!
One command re-renders all 547 widgets and diffs them against the golden screenshots with ImageMagick RMSE at a 0.5% threshold. Every passing widget measured 0.0000% — pixel-identical. C 544/547, Python 547/547, Rust 537 + 9/9 on re-run.
Every widget LightGUI ships — all 547 of them — now gets re-rendered and compared pixel by pixel against its golden screenshot on every run of the visual regression harness. One command per repo, zero tolerance for silent drift: tools/visreg/run.sh (or make visreg in C). The first full sweep across all three designers came back with every passing widget at 0.0000% RMSE — not "close enough", not "within tolerance", but pixel-identical to the goldens.
That number deserves the emphasis, because it is the whole point. A widget library that renders slightly differently every build is a library you can't trust: a one-pixel border shift here, a clipped label there, and six months later your generated apps look nothing like the screenshots in the docs. The harness exists so that never happens silently again.
What the harness does
It re-renders all 547 widgets exactly the way the documentation screenshot sweep did — same renderer, same layout, same environment under Xvfb — and diffs each fresh render against the golden screenshot captured for that widget, using ImageMagick's compare with an RMSE (root-mean-square error) metric and a 0.5% threshold. Below the threshold: pass. Above it: fail, with the diff to look at. Widgets that can't be compared deterministically are skipped explicitly, never silently dropped — a skip is a reported outcome, not an absence.
One command runs the whole thing in each repo:
tools/visreg/run.sh # C, Rust, Python
make visreg # C only, same harness
The goldens are the screenshots from the documentation sweep — the same images published on the widget documentation blogs — so the harness also guards the docs: if a widget's rendering drifts, its documentation screenshot is now wrong too, and the harness says so before anyone ships it.
The results
| Designer | Pass | Fail | Skip | Commit |
|---|---|---|---|---|
| C (cnmcdee/lightgui) | 544 | 0 | 3 | 7d7fa6c |
| Python (cnmcdee/lightgui_python) | 547 | 0 | 0 | bfb366c |
| Rust (cnmcdee/lightgui_rust) | 537, then 9/9 on re-run | 9 on first run, 0 after disposition | 0 | 414cfe2 + d507697 |
And the number that matters most: every passing widget in all three repos measured 0.0000% RMSE. The re-renders are pixel-identical to the goldens — not merely inside the 0.5% threshold, but exactly equal. The threshold is a tripwire for future drift, not a fudge factor the current results needed.
The three C skips are deliberate
C reports 544 pass, 3 skip, 0 fail. The three skips are the wall-clock widgets — TTimeEdit, TDateEdit and TCalendar — and they are skipped because they are proven time-dependent: they render the current time and date, so two renders taken a second apart legitimately differ. No threshold would fix that; comparing them would produce a failure every time the clock ticks, which teaches everyone to ignore the harness. They are skipped by name, listed in every run's output, and the skip list is part of the harness — adding a fourth skip requires changing the harness, not forgetting a widget.
The nine Rust failures — and what they actually were
Rust is the only repo that failed anything on its first run: 537 pass, 9 fail. All nine were dispositioned individually, and none of them was a widget rendering wrong:
- Five were stale goldens, not broken widgets. Their golden screenshots from the documentation sweep were mid-draw captures — taken while the widget was still painting — so the golden itself was a torn frame. Each golden was refreshed and then verified bit-stable across repeated captures before being accepted. The widget was rendering correctly all along; the reference image was the defect.
- Four were "no window" flakes under parallel load. Under a parallel run, four widgets intermittently produced no window at all to capture — a load-dependent flake in the capture environment, not in the widget drawing code. A confirmation re-run passed 9/9, and the re-run is the result that stands.
This is the honest part of the story, and it matters: a regression harness that cries wolf nine times on its first run is a harness people learn to ignore. Each failure got a cause, a fix, and a re-run — the goldens were only refreshed after proving the new captures were bit-stable, and the flakes were only closed after a clean 9/9 confirmation run. Commits 414cfe2 and d507697 carry the harness and the dispositions.
Why 0.0000% matters
A 0.5% RMSE threshold sounds strict until you realise what it permits: a widget could shift a border by a pixel or two in a corner and still pass. A 0.0000% result means that didn't happen anywhere — 544 widgets in C, 547 in Python, 546 in Rust (537 + 9) re-rendered bit-for-bit identical to the images already published in the docs. Three independent renderers, three widget implementations, one shared visual contract, and all three meet it exactly.
That also means the harness is now a tripwire with a hair trigger in practice: any future change that moves a single pixel in any widget will show up as a non-zero RMSE on the very next run, with the widget named and the diff in hand. The next person to touch a draw routine will know within one command whether they changed what the widget looks like — which is exactly the question a widget library needs answered before every release.
What this does not cover
Honesty requires the limits too. The harness checks that each widget renders the same as its golden — it does not check that the golden was ever right. A widget that has always drawn its border one pixel too far left will pass forever, because the golden has the same error. Catching that needs a human looking at the picture, which is what the documentation screenshot review already does. The harness guarantees stability, not correctness.
It also doesn't cover interaction: a widget can render perfectly and still mishandle a click, a keypress, or a resize. Rendering is one axis; the debugger fixes, the event-dispatch fixes, and the widget test suites cover the others. And the four Rust "no window" flakes are a reminder that the capture environment itself has load limits — if parallel flakes recur, the answer is to throttle the parallelism, not to raise the threshold.
Run it yourself
Clone any of the three repos, and run the harness:
tools/visreg/run.sh
It needs Xvfb and ImageMagick — the same dependencies the documentation screenshot sweep uses. A clean run ends with 547 widgets accounted for (pass, fail, or explicit skip) and every passing widget at 0.0000% RMSE. Anything else is a result to investigate, not noise to wave through — that is the entire deal.