Bypass change detection when taking a mut ref to editable_text in update_editable_text_layout - #25525
Bypass change detection when taking a mut ref to editable_text in update_editable_text_layout#25525gagnus wants to merge 2 commits into
Conversation
…ate_editable_text_layout, otherwise the component is marked dirty every frame which causes massive frame rate degredation, especially in debug builds
ickshonpe
left a comment
There was a problem hiding this comment.
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.
Cyannide
left a comment
There was a problem hiding this comment.
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.
…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.
otherwise the component is marked dirty every frame which causes massive frame rate degredation, especially in debug builds