Skip to content

cvcGL: golden-image tests for the Ariadne ImGui/VTK backend (§16.6 phase 1) - #725

Merged
transfix merged 9 commits into
masterfrom
test/ari-golden-harness
Oct 21, 2026
Merged

transfix merged 9 commits into
masterfrom
test/ari-golden-harness

Conversation

@transfix

@transfix transfix commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Roadmap §16.6 phase 1: the Ariadne ImGui/VTK backend's rendering becomes CI-testable instead of only compile-checked.

What it does

cvcgl_ari_golden runs every .ari in src/cvcGL/test/golden/ through AriRuntime + ImGuiBackend, the same path pycvc_gl and the GL hosts use. Each document renders offscreen at 960x720 with the overlay visible, and the frame is compared with <name>.png. AriRuntime is used as it is, unmodified.

document covers
windows.ari pos, px and fractional sizes, closable:, frame: {border}, tinted text
menus.ari the menu bar, with File opened by a scripted click: checked and unchecked toggles, a separator, actions
widgets.ari one of each widget kind, plus disabled, visible_when, a computed bind:, and a hovered tooltip
grid.ari a table with every border, inner borders in a custom colour, a resizable row split
scene.ari a box and a sphere framed by the runtime, under a window

Repeatable captures:

  • a pinned UI font, Liberation Sans (OFL), shipped in golden/fonts with its licence;
  • UI scale 1, touch off, the show/hide button hidden, panels open, 960x720 so the under-700-px rule never closes them;
  • ImGui's frame delta pinned, and at least 4 frames at a fixed dt;
  • a check that one more frame draws identical pixels, so a UI that is still changing fails as unsettled, not as a flaky mismatch.

Comparison: golden_util.h is a reusable helper. It uses VTK's PNG reader and writer (no ImageMagick coder involved) and takes a per-channel tolerance plus a maximum mismatch fraction. On a failure it writes <name>.actual.png + <name>.diff.png (mismatches red, the golden dimmed underneath) and reports the count and bounding box. CVC_UPDATE_GOLDEN=1 regenerates. Reference goldens can only be written under llvmpipe; CVC_GOLDEN_VARIANT writes a platform golden <name>.<variant>.png, which defaults to macos on Apple.

Tolerance (measured, not guessed). The goldens were made under cvcpkg's Mesa 25.3.6 llvmpipe on Xvfb, as in CI. The table counts pixels differing by more than 8 / more than 40 in a channel:

renderer or change >8 >40
Ubuntu's Mesa 25.2.8 llvmpipe ≤1312 0
NVIDIA GTX 1650 ≤1 0
Agents slider 64 → 65 (one step) 232 144
Widgets window moved 1 px down 15240 12167

So the test allows ±40 a channel, with at most 0.002% of pixels (13) beyond it. Every comparison prints its spread. CI prints those numbers from LastTest.log on every run, pass or fail, and uploads the PNGs when a libcvc job fails (ari-golden-<OS>-<lane>). macOS and Windows numbers will show up there. If Apple's GL needs its own pictures, they become *.macos.png from that artifact.

Two small ImGuiOverlay changes

  • setFixedDeltaTime() pins io.DeltaTime. The default is still the wall clock.
  • A failed ImGui GL backend init is no longer retried. Under VTK's EGL fallback (no X display), the first ImGui_ImplOpenGL3_Init fails and the retry segfaulted on a null GL_VERSION. imgui's loader goes through GLX, so the failure latch is process-wide. enabled() now reports the failure, and the test skips, or fails under CVC_REQUIRE_RENDER=1.

Found by the goldens (not fixed here; the docs steer around them)

  • A window with no size: stays at ImGui's 32 px minimum. On the window's first frame, ariadne.cpp (§11.4) persists the size before ImGui has fitted it. On the next frame it seeds that size back through SetNextWindowSize(..., FirstUseEver), which cancels the auto-fit. This affects hello.ari's Controls window too.
  • A declared directional light: leaves the realized scene unlit, for any azimuth, with or without shadows. hello.ari's bunny renders dark brown in ariadne_hello too, on llvmpipe and on NVIDIA. scene.ari uses the fallback headlight instead.
  • layout: {kind: horizontal} is ignored on a window body. The embedded schema also rejects the size: {hint,min,max} map and "50%" strings that the loader accepts.

CI never built the ImGui backend (fixed here)

The first CI run passed cvcgl_ari_golden on every lane, but only because it skipped. No CI job installed imgui, so every CI build of cvcGL compiled ImGuiOverlay and the Ariadne ImGui backend as inert stubs (cvcGL: imgui not found). The macOS and Windows package lanes also lacked yaml-cpp. Commit a598d8a fixes this:

  • the package lanes now install imgui, plus yaml-cpp on macOS and Windows, from cvcpkg;
  • under CVC_REQUIRE_RENDER=1, a build without ImGui or without the YAML loader now fails rather than skips, so the Linux job can't quietly pass again.

The failing package-macos / libcvc-release-grpc-static check fails the same way on master at 381cadc (run 39303777747). dyld can't load @rpath/libcares.2.19.3.dylib, which libgrpc.44.1.1.dylib needs, so ctest stops during gtest discovery. It is unrelated to this PR.

CI numbers (a598d8a, imgui installed)

lane renderer largest channel diff px differing by >0 (worst doc) px beyond 8
package-linux release + debug llvmpipe, LLVM 20.1.8 (cvcpkg Mesa) 1 20 (widgets) 0
package-windows release llvmpipe, LLVM 22.1.8 (mesa-dist-win 26.1.7) 1 313 (windows) 0
package-macos release-grpc Apple Software Renderer 118 12957 (menus) 209-2215

On macOS, the pixels beyond ±40 (limit 13) were: windows 3, menus 4, grid 6, widgets 40, scene 467. They are all on anti-aliased edges and silhouettes. The renderer is deterministic: every document settled to identical frames. I didn't loosen the tolerance, because that would let a one-step value change through. Instead, 0a3640a commits that job's own actual frames, taken from its ari-golden-macOS-libcvc-release-grpc artifact and checked by eye, as widgets.macos.png and scene.macos.png. macOS compares those two documents against its own renderer.

Also in this PR: with real imgui on Windows, #727's cvcgl_imgui_table_columns segfaulted. Its ImGui context lived in the test exe's static copy of imgui, not in cvcGL.dll's. 7d0feee adds ImGuiBackend::setImGuiContext(ctx), and the test hands its context to cvcGL with it.

The same run's recipe / ubuntu-latest / Debug failed ModelTest.ObjWithUvsMaterialTexture. That's a pre-existing race, fixed in 40fde8f: two ModelTest cases wrote the same OBJ/MTL/PNG fixture into gtest's TempDir, ctest ran them in parallel, and one read the PNG while the other was rewriting it. Each case now writes into its own directory.

Verified locally

  • Release, shared build, under cvcpkg Xvfb + Mesa llvmpipe: cvcgl_ari_golden is byte-exact, ×3 via ctest --repeat until-fail:3. The full cvcgl_* suite passes 70/70.
  • NVIDIA and Ubuntu's Mesa llvmpipe both pass.
  • With no DISPLAY (EGL), the test skips with rc 0, and fails with rc 1 under CVC_REQUIRE_RENDER=1.
  • The two deliberate changes in the table above both fail, with the diff and the bounding box reported.
  • clang-format 18.1.8 (cvcpkg) is clean on the changed lines. ci.yml keeps its CRLF line endings.

docs/ARIADNE.md §12 explains how to add a golden test and regenerate goldens.

…§16.6 phase 1)

cvcgl_ari_golden runs every .ari in src/cvcGL/test/golden through AriRuntime +
ImGuiBackend offscreen (960x720, overlay visible) and compares the frame with the
PNG of the same name. Five documents: windows, menus (File opened by a scripted
click), every widget kind (with a hovered tooltip), grid layouts, and a scene.

Repeatable captures: a pinned OFL font (Liberation Sans, shipped in the test
tree), UI scale 1, touch off, the show/hide button hidden, panels open, ImGui's
frame delta pinned, >= 4 frames at a fixed dt, and a check that one more frame
draws the same pixels.

Comparison (src/cvcGL/test/golden_util.h, reusable): VTK PNG I/O, a per-channel
tolerance and a max mismatch fraction, actual.png + diff.png on failure, and
CVC_UPDATE_GOLDEN=1 to regenerate (reference goldens only under llvmpipe;
CVC_GOLDEN_VARIANT for platform goldens). +-40 a channel with at most 0.002% of
pixels beyond it was measured to pass Ubuntu's Mesa 25.2.8 llvmpipe and an
NVIDIA GPU against the cvcpkg Mesa 25.3.6 goldens, and to fail a one-step slider
change (144 px) and a window moved by one pixel (12167 px).

ImGuiOverlay:
- setFixedDeltaTime() pins io.DeltaTime (0 = wall clock, the default).
- A failed ImGui GL backend init is no longer retried: under VTK's EGL fallback
  (no X display) the retry crashed on a null GL_VERSION. enabled() now reports
  it, and the test skips (fails under CVC_REQUIRE_RENDER).

CI prints each document's numbers from LastTest.log on every run and uploads
the actual/diff PNGs when a libcvc job fails. docs/ARIADNE.md §12 covers adding
a golden test and regenerating goldens.
… renders

The first CI run of #725 passed cvcgl_ari_golden on every lane only because it
skipped: no CI job installs imgui, so every CI build of cvcGL compiled
ImGuiOverlay and the Ariadne ImGui backend as inert stubs ("cvcGL: imgui not
found"), and the macOS/Windows package lanes have no yaml-cpp either.

- package-linux: cvcpkg install imgui next to the Ariadne optional deps.
- package-macos / package-windows: cvcpkg install imgui yaml-cpp next to vtk.
- cvcgl_ari_golden: a build without ImGui or the YAML loader (like a GL the
  overlay cannot start on) fails under CVC_REQUIRE_RENDER instead of skipping,
  so the Linux job cannot quietly pass again.
ModelTest.ObjWithUvsMaterialTexture and ModelTest.ReadGeometryObjFlatten both
wrote the same OBJ + MTL + PNG fixture into gtest's TempDir. ctest runs them as
parallel processes, and #725's recipe / ubuntu-latest / Debug job started the
two together: one read cvc_model_test_tex.png while the other was rewriting it
("cvc::image stb read ... unknown image type"), so the texture was dropped and
the test failed. Each case now writes into TempDir()/cvc_model_test_<name>/;
the file names, and so the .obj/.mtl references and the asserted texture path,
are unchanged.
…every cvcgl_* ctest)

Master's #583 removed cvcgl_test::disableSwapThrottle() and sets
__GL_SYNC_TO_VBLANK=0 / vblank_mode=0 on every test in src/cvcGL through
ctest's ENVIRONMENT, which covers cvcgl_ari_golden too; the merge left the
call behind and package-linux / libcvc-debug failed to compile it.
…den-harness

# Conflicts:
#	src/cvcGL/CMakeLists.txt
…aches libcvcGL

cvcgl_imgui_table_columns (#727) segfaulted on package-windows once #725 put a
real imgui into the Windows CI build. The test creates its ImGui context in
the test executable and drives ImGuiBackend, which runs inside cvcGL.dll. The
cvcpkg Windows imgui is a static library, so the exe and the DLL each carry a
copy of imgui with its own current context, and the backend found none.
(ImGuiOverlay creates its context inside libcvcGL, so overlay hosts never hit
this; a shared imgui, as on Linux, has one copy.)

ImGuiBackend::setImGuiContext(ctx) makes ctx current in libcvcGL's copy; the
test hands its context over after CreateContext and clears it before
destroying it, which it now does by pointer (with a shared imgui clearing
libcvcGL's current context clears the test's too).
… Renderer)

macOS CI (package-macos / libcvc-release-grpc, run 39427493969) renders with
the Apple Software Renderer: deterministic (each document settles to identical
frames), but its anti-aliased edges and shading differ from llvmpipe. Against
the llvmpipe goldens windows / menus / grid had 3-6 px beyond +-40 (pass,
limit 13), widgets 40 and scene 467 (fail; all on edges and silhouettes).

Rather than loosen the tolerance until a one-step value change passes, those
two get macOS platform goldens, the job's own actual frames from the
ari-golden-macOS-libcvc-release-grpc artifact, looked at before committing.
docs/ARIADNE.md section 12 records the numbers and how to refresh a macOS
golden from the CI artifact.
@transfix
transfix merged commit 406ff26 into master Oct 21, 2026
24 checks passed
@transfix
transfix deleted the test/ari-golden-harness branch October 21, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant