Skip to content

Layout debug overlay (F12), and a CI failure summary - #28

Merged
samitbasu merged 3 commits into
mainfrom
debug-overlay
Nov 8, 2026
Merged

samitbasu merged 3 commits into
mainfrom
debug-overlay

Conversation

@samitbasu

Copy link
Copy Markdown
Owner

Closes #25. Refs #27 (not reproduced; left open).

Debug overlay (#25)

  • bullseye::Debug (Off by default, Outlines) lives in the egui context: Debug::of, set, toggle, toggle_on(ctx, Key). One F12 handler then governs every tree drawn in the frame. When Off it costs one context read per layout and per draw, with no shapes and no per-node allocation.

  • Drawing: on a top-most Order::Debug layer, every node's border box is outlined with a 1-physical-pixel hairline. That includes anonymous nodes, leaves and overlay roots.

  • Red means content didn't fit. This is exact, not a heuristic:

    • Leaves: when the overlay is on, layout re-measures each leaf at its final content width. The leaf is red if that measured size exceeds its content box by more than 0.5 pt. The tolerance absorbs egui's galley rounding, and truncated text is exempt.
    • Containers: red if an in-flow child extends past the container's padding box on an axis it doesn't clip.
  • Hover: the innermost node under the pointer is labelled with its readable path, its rect and its size.

  • Examples: F12 toggles it through one helper, common::toggle_debug, which every example reaches.

  • Tests: tests/debug.rs has 6 tests:

    • Off draws nothing extra;
    • one outline per node, at its rect;
    • the red and neutral cases;
    • the hover label;
    • toggling.

    The golden is debug_overlay_todo.

CI failure summary (#27)

  • Not reproduced:

    • 25 full test runs at default parallelism and 3 single-threaded;
    • 450 runs of tests/layout.rs, which shares a static context, at 1, 2 and 64 threads, pinned to 2 CPUs;

    all passed.

  • Reentrancy audit: every lock-taking Context / Ui closure in src/, tests/ and examples/ was checked, and none calls another context method. Two harmless unique_id() reads inside data closures were hoisted out anyway, so the pattern doesn't get copied.

  • A failed step now ends with one line: the failing test names, and the first panic as file:line:col and message. A compile error or fmt diff shows its first line instead. The parser is a pure function (xtask/src/summary.rs) with 7 unit tests.

  • Behaviour changes:

    • cargo xtask ci runs every step instead of stopping at the first failure, so a lint failure can't hide a test failure. The exit code is still non-zero on any failure.
    • Cargo output is no longer coloured.
  • The remaining lead, if the failure recurs: the trybuild compile-fail test is slow (53 s in one run) and shares the target directory.

To try (UI)

cargo xtask example todo     # press F12; hover nodes

The overlay's colours (outline #6c8ebf, overflow #ff3030) and its label style are open for review.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up

samitbasu and others added 2 commits November 8, 2026 11:46
`Debug::Outlines`, set on the egui context with `Debug::set` (or flipped by
`Debug::toggle_on(ctx, key)`), makes `Placed::draw` outline every node's border
box with a one-physical-pixel hairline on the topmost debug layer, and label the
innermost node under the pointer with its readable path and rect.

The mode lives in the context, not in `LayoutState`, so one key binding
governs every tree drawn in a frame (an example draws a theme bar and a page
with separate states). Off costs one context read per layout and per draw:
no shapes, no per-node allocation.

A node is outlined in red when its content did not fit. For a leaf, layout
re-measures it at its final content width when the overlay is on and records
the size its text or measure wants (`PlacedNode::measured`); it did not fit
if that exceeds the content box on either axis by more than half a point
(truncated text is cut to the box by design). A container did not fit when
an in-flow child extends past its padding box on an axis it does not clip.

The examples bind F12: `ThemeBar::show` (so everything that shows the bar,
and the shared runner) and chat_shell call the one `common::toggle_debug`.

Tests are shape-based (kittest harness): off emits nothing and leaves the frame
unchanged, one outline per node at its rect, red for a nowrap text leaf, a too
tall leaf and a spilling child but not a fitting, clipped or wrapping one,
hover labels the innermost node, the toggle key. One snapshot golden,
debug_overlay_todo.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
…t panic (#27)

The `ci` job failed once on PR #17 and passed on re-run, and the raw log had
expired before anyone read it. Cargo output is now captured (stderr merged
into stdout) while it is streamed unchanged to stderr, and a failed step is
summarised in one line: its status, every `test ... FAILED` with the test
binary it ran in, and the first panic's location and message, or for a step
with no test failure its first compiler or rustfmt complaint. The summary
logic is a pure function with unit tests over sample cargo output.

Behaviour changes: `run_all` runs every step instead of stopping at the first
failure, so a lint failure no longer hides a test failure; and cargo output is
no longer a terminal, so it is not coloured.

No reentrancy bug of the class fixed in 2daaebd was found by auditing every
`Context` closure in src and tests (see the issue); the two draw.rs sites that
evaluated `ui.unique_id()` inside a `data` closure now read it first. They did
not lock, so this changes no behaviour.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
CI's ci and coverage jobs died with `ld terminated with signal 7 [Bus
error]`: the runner ran out of disk. Each of the 24 files in tests/ was
its own test crate statically linking egui/eframe/egui_kittest, 400-700 MB
apiece with debuginfo.

- tests/*.rs are now modules of one crate, tests/it/main.rs; the shared
  support module sits beside them. The golden-image tests are a
  `#[cfg(feature = "snapshots")]` module of the same binary instead of a
  required-features target. trybuild's compile_fail is a module too. Test
  bodies are unchanged; their paths gain a module prefix. Four modules
  are renamed *_demo because they clash with the example they include.
- `cargo xtask snapshots` runs `--test it` filtered to `snapshots::`.
  Behaviour change: `--filter NAME` now matches goldens whose name starts
  with NAME (it was a substring match).
- ci.yml: CARGO_PROFILE_{DEV,TEST}_DEBUG=line-tables-only (panics keep
  file:line) and a `df -h` / `du -sh target` step that always runs.
- xtask summary: strip ANSI escapes (CI sets CARGO_TERM_COLOR=always) and,
  when a step fails without test failures, report `could not compile
  <crate> (<target>)` with the first `fatal error:` or error line. Tested
  against an excerpt of the real failing log.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PWiKKe8zfqGfVMCSC5L3up
@samitbasu
samitbasu merged commit 5ab293a into main Nov 8, 2026
3 checks passed
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.

Layout debug overlay: hairline outline of every node's rect

1 participant