Repository navigation
Run every rendering callback in one pass per frame - #1154
Merged
Merged
Conversation
rendering.js now owns the one animation frame Leaf asks for. nextRender queues into it, and work a callback queues runs in the same pass, before the frame paints: a repaint that moves the page and the target boxes, design legend and action bar that follow it land in one frame instead of one frame apart. A chain that keeps asking finishes on the next frame after eight generations. The pass waits a microtask step between callbacks, as the browser does between its own, and reports a callback's error without stopping the owners after it. nextFrame is the call for a step that must not run in the pass that asked for it; the scroll glide, the place-hold follow loop and the interaction gallery's frame pause move onto it, since each re-asks from inside its own callback. Measured on triage-board with design mode on, narrowing the window: the settled reading holds two frames after the resize against three on main, in every one of 20 paired trials. Behavior that moved: tests/runtime/rendering.test.mjs's "work a callback queues for the next update" now asserts the opposite for nextRender and holds nextFrame to the old timing. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
leaf-agent
approved these changes
Sep 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Leaf's chrome and geometry had about 20 owners, each asking the browser for its own animation frame. Work one frame callback queued for another ran a frame later, so anything that follows the page — target boxes, the design-mode legend, the action bar — painted one frame behind a repaint that moved the page, and the settled reading (#1145) needed an extra frame to say so.
runtime/rendering.jsnow owns the one frame Leaf asks for:nextRenderqueues into one pass per frame. Asked for from inside the pass, it runs in that pass, before the frame paints; asked for anywhere else (an input handler, a ResizeObserver delivery), it runs in the next frame's pass. A chain that keeps asking stops after eight generations and finishes on the next frame.nextFrameis for a step that must not run in the pass that asked for it. The scroll glide (navigation.js), the place-hold follow loop (user-place.js) and the interaction gallery's frame pause move onto it, since each re-asks from inside its own callback. It is exported through the widget API for a package's own animation tick.No other caller changes. Every other
nextRendercaller was checked: those reached from inside a pass are coalescing paint and placement (repaint, page geometry, target paint, the legend, margin layout and projection, the FAB, the TOC) and run correctly in the same pass; the rest are asked for from input or observer callbacks, whose timing is unchanged.Measured on
triage-boardwith design mode on, narrowing the window: the settled reading holds two frames after the resize against three on main, in all 20 paired trials.This replaces the planned move of target and legend boxes to CSS anchor positioning, which Chrome 154 can't carry: an anchored box isn't clipped by its target's scroll container, an anchor inside a widget's shadow root is invisible to chrome outside it, and a
display: contentselement is no anchor at all.Checks:
npm run test:runtime, the everyday suite, and the complete nightly suite (3150 passed) on the branch before the merge of main.🤖 Generated with Claude Code