Fix debug-profile slider stutter (#25500) - #25536
Open
bugsweeper wants to merge 2 commits into
Open
Conversation
EditableText re-triggered intrinsic-size recomputation and a full Taffy layout pass every frame regardless of whether its rendered size had actually changed, and ColorSlider/ColorPlane moved their thumb via Node::left/top (layout-affecting properties), forcing a relayout on every frame during drag. In debug builds this made the color slider/plane update in visible discrete steps instead of smoothly. - Cache the inputs that determine EditableText's intrinsic size (visible_width/visible_lines) and only recompute when they change. - Move ColorSlider and ColorPlane thumb positioning to UiTransform, which doesn't invalidate layout, instead of Node::left/top. - Split ColorPlane's thumb positioning into its own unfiltered system so it keeps tracking the container's resized size every frame, while update_plane_color keeps its Changed filter to avoid needlessly mutating Assets<ColorPlaneMaterial>. Debug-profile FPS during continuous slider drag went from ~11-14 FPS to ~59-63 FPS on Linux + NVIDIA RTX 4070 + Vulkan.
Contributor
Author
|
The macOS build job did not report a test failure; it was cancelled after reaching the workflow’s 40-minute timeout while running cargo run -p ci -- test. Ubuntu and Windows builds passed, as did run-examples-macos-metal. I’ll update the branch against current main to trigger a fresh run. If macOS times out again, could a maintainer please rerun the failed job? |
…sue-25500-slider-debug-perf # Conflicts: # crates/bevy_feathers/src/controls/color_slider.rs
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.
Objective
feathers_gallerypoor performance in debug mode #25500.feathers_galleryupdated in visible discrete steps instead of smoothly. Measured on Linux + NVIDIA RTX 4070 + Vulkan: out of 138 consecutive frames during a slow, controlled drag, only 86 states were unique (52 frames repeated the previous state) in debug, versus 129/138 unique in release. The slider's value updated correctly the whole time — this was a rendering smoothness problem, not an input problem.EditableTexttriggered a full intrinsic-size recomputation (and thus a full Taffy layout pass) every frame, regardless of whether its rendered size had actually changed.ColorSliderandColorPlanemoved their thumb every frame by writingNode::left/Node::top, which are layout-affecting properties and force a Taffy relayout on every frame during a drag.Solution
update_editable_text_content_sizenow caches the inputs that actually determineEditableText's intrinsic size (visible_width,visible_lines) in a newEditableTextContentSizeStatecomponent, and only recomputes when those specific fields change, instead of on every change toEditableText(which also churns from unrelated fields like cursor blink/edits).EditableTextContentSizeStateis wired up as a required component ofbevy_text::EditableTextviaregister_required_componentsinUiPlugin, sincebevy_textdoesn't depend onbevy_ui.ColorSliderandColorPlanenow position their thumb viaUiTransforminstead ofNode::left/Node::top.UiTransformis applied after layout and doesn't invalidate Taffy, so moving the thumb no longer forces a relayout.ColorPlane's thumb positioning was split out ofupdate_plane_colorinto its own system,update_plane_thumb_position, which runs unconditionally every frame so the thumb keeps tracking the parent node's actual size (e.g. on window resize) even when the color value hasn't changed.update_plane_colorkeeps its originalChangedfilter, since it mutatesAssets<ColorPlaneMaterial>, which is comparatively expensive to touch every frame.Testing
cargo test -p bevy_ui --lib: 66/66 passed.cargo test -p bevy_feathers --lib: 10/10 passed.cargo fmt --checkandgit diff --checkpass.feathers_gallery(debug profile) that the color slider and color plane thumbs track the mouse correctly and land at the right position during and after a drag.