Skip to content

Bypass change detection when taking a mut ref to editable_text in update_editable_text_layout - #25525

Open
gagnus wants to merge 2 commits into
bevyengine:mainfrom
gagnus:bevy-update_editable_text_layout-fix
Open

Bypass change detection when taking a mut ref to editable_text in update_editable_text_layout#25525
gagnus wants to merge 2 commits into
bevyengine:mainfrom
gagnus:bevy-update_editable_text_layout-fix

Conversation

@gagnus

@gagnus gagnus commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

otherwise the component is marked dirty every frame which causes massive frame rate degredation, especially in debug builds

image

gagnus added 2 commits August 23, 2026 18:32
…ate_editable_text_layout, otherwise the component is marked dirty every frame which causes massive frame rate degredation, especially in debug builds
@Zeophlite
Zeophlite requested a review from ickshonpe August 24, 2026 02:02
@Zeophlite Zeophlite added C-Bug An unexpected or incorrect behavior A-UI Graphical user interfaces, styles, layouts, and widgets D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Aug 24, 2026
@github-project-automation github-project-automation Bot moved this to Needs SME Triage in UI Aug 24, 2026
@Zeophlite Zeophlite added this to the 0.20 milestone Aug 24, 2026

@ickshonpe ickshonpe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes here seem obviously correct, but something feels off, I didn't spend that long looking into this, but the performance isssues seem to be inconsistant, sometimes feathers_gallery runs fine even on main in debug mode. Also the difference, 16ms vs 90ms, shouldn't be that dramatic. Even if it is relayouting the text inputs every frame, there aren't many of them and they only contain a couple of glyphs.

Anyway, approve but might also need further investigation.

@ickshonpe ickshonpe modified the milestones: 0.20, 0.19.2 Aug 24, 2026

@Cyannide Cyannide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went ahead and instrumented the text_input example to make sure changes are still triggered for non-edit events. Idle frames no longer report at all and I can confirm that mouse clicks, mouse select, all keyboard edits and cursor movement still set changed.

Cyannide added a commit to Cyannide/bevy that referenced this pull request Aug 24, 2026
…every frame

update_editable_text_layout takes editor.driver() through &mut, which
marked every field Changed on every frame -- wasted change-detection work
downstream on every rendered field, per frame, per field. Verified
upstream with an instrumented example before this backport: idle frames
now report nothing, and every real interaction (edits, clicks, selection,
cursor movement) still fires from its owning system's ordinary &mut.

The fork's fn is simpler than main's patch target (no viewport scroll
yet), so the backport is the pattern, not the diff: bypass at the top,
set_changed at the bottom when the layout generation moved. set_width is
covered by the same generation bump.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

4 participants