Repository navigation
fix(relayout,kit-gallery): keep resize relayout with fitted overlays/images and virtualize gallery index - #2308
Merged
Merged
Conversation
…images and virtualize gallery index Keep CommitKind::Relayout active across viewport resizes when trees hold El::anchored_fit overlays (saving and restoring unclamped styles before fit_anchored re-clamps), El::aspect_fit elements (restoring fit_room before solve re-fits), or El::pixels pictures whose decoded aspect ratio is unchanged. Virtualize examples/kit-gallery's default index with virtual_rows so only mounted stories build (~314 nodes vs ~11,910), stop menu_submenu_small_window from opening a stray context menu in index mode, and give every gallery story unique overlay keys and combobox state so opening overlays never mounts duplicate sibling keys (model-scrim, model-content, etc.) under kit-root.
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.
Root cause
CommitKind::Relayoutbailed out on fitted overlays,aspect_fit, andpixel_aspect(crates/rune/src/runtime/commit/relayout.rs):commit_kindcheckedself.tree.nodes.iter().all(reusable), which rejected any tree containing anEl::anchored_fitoverlay (every openrune-kitSelect,Combobox,Menu,Popover,HoverCard, orPopupList), anEl::aspect_fitelement, or anEl::pixelspicture sizing one side from its aspect ratio. Any such node forced a fullCommitKind::Rebuild(re-runningview(), flattening, and diffing the entire tree) on every drag-resize frame.examples/kit-gallerymounted all 183 stories at once inindexmode (examples/kit-gallery/src/stories.rs): launchingkit-gallerywithout--scenestacked all 183 stories into an un-virtualizedcol()(~11,910 mounted nodes), whilerune-menu--submenu-small-window(examples/kit-gallery/src/stories/field_menu.rs) unconditionally opened a context menu at(130, 60)withanchored_fit, defeatingRelayouton every resize step even when no overlay was opened by the user.kit-root(examples/kit-gallery/src/stories/combobox.rs,stories.rs,inputs.rs,overlays.rs):rune-combobox--searchableandrune-combobox--animated-filterboth mountedCombobox::new("model", &s.combo, ...)using the same key and sharedComboboxState, so opening the combobox inindexmounted twomodel-scrimand twomodel-contentsiblings underkit-root. SeveralDialog,Select,Menu,Popover, andTooltipstories likewise shared keys ("dialog","select","menu","popover","tip") and state.What changed
crates/rune(runtime/commit/relayout.rs,runtime/anchor.rs,runtime/commit.rs,runtime/commit/measure.rs,runtime/commit/apply.rs,runtime/commit/remount.rs):fit_anchoredrecords each clampedanchored_fitoverlay's authored unclampedCompactStyleintoMeasured::above_fit_styles->Reuse::above_fit_styles(empty vec / zero allocation when no overlay is clamped).Measurement::relayoutrestores any clampedabove_fit_stylesand resetsaspect_fitnodes tofit_roombefore callingsolve, so both re-fit cleanly against the new viewport without runningview()or flattening.commit_kindkeepsCommitKind::Relayoutwheneverpixel_aspects_unchanged(&self.tree)holds, rebuilding only when a picture's decoded ratio actually changed.crates/rune/src/runtime/tests/relayout.rsverifying 0 view runs and exact layout parity with a full rebuild foraspect_fit, clamped/unclampedanchored_fitoverlays with nested submenus, and unchanged vs changedpixel_aspect.examples/kit-gallery(src/stories/index.rs,src/stories.rs,src/main.rs,src/stories/combobox.rs,src/stories/field_menu.rs,src/stories/inputs.rs,src/stories/overlays.rs,src/stories/table.rs,scripts/combobox-animated-filter.json,src/gallery_tests.rs):indexinsrc/stories/index.rswith a scroll container andvirtual_rowsso only visible stories + overscan mount (~314 nodes vs ~11,910), collecting open overlays separately underkit-root.menu_submenu_small_window's default anchor point to its own scene so it no longer opens a stray menu inindex.ComboboxStatefields (combo,combo_animated,combo_localized) and taggedtable_menuby story; added standing tests insrc/gallery_tests.rsasserting virtualization, zero-view relayout on resize, and zero duplicate sibling keys across every story and every open overlay inindex.Headless drag-resize benchmark (
--profile perf,rune/frame-profile)Paired, alternating runs (5 pairs = 10 runs, 60 drag-resize steps
800x560->1220x800->800x560at 1x scale, reported by median with p90 and worst-frame outlier kept; headless measurements exclude GPU encode, upload, and presentation):kit-galleryindex (closed)kit-galleryindex (combobox open)virtual_rows+ open Popoveraspect_fit+pixel_aspectpageAt 0.40–0.45 ms median CPU per resize step (p90 0.52–0.59 ms, worst 3.07 ms on virtual-window growth),
kit-galleryand all measured app shapes stay well inside 60 Hz (16.7 ms), 120 Hz (8.3 ms), and 240 Hz (4.17 ms) CPU budgets, leaving GPU upload/presentation under ~1 ms.Not checked