bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Don't update the text buffer in `text_system`

Open ickshonpe opened this issue 1 month ago • 1 comments

Objective

Text is shaped in measure_text_system. When the schedule reaches text_system there's no need to reupdate the cosmic-text buffer a second time. text_system should only be updating any stale TextLayoutInfo components.

Solution

  • Add a new method update_text_layout_info to TextPipeline. This method updates the given TextLayoutInfo without performing any shaping.
  • Call update_text_layout_info instead of queue_text from text_system.
  • Only query for TextFont, instead of the full TextUiReader.

The next step is to remove TextPipeline::queue_text. I didn't do that here as it's a fairly large refactor and I have a bunch of other open text PRs I'd like to get merged first.

Testing

yellow = this PR, red = main

cargo run --example many_glyphs --release --features trace_tracy,debug -- --no-text2d --recompute-text
Screenshot 2025-11-28 130411
cargo run --example many_buttons --release --features trace_tracy,debug -- --text --respawn
Screenshot 2025-11-28 145240

ickshonpe avatar Nov 28 '25 13:11 ickshonpe

Makes sense to me. Thanks for including the traces, seems like a pretty big win.

The benchmark is very synthetic, most applications aren't going to redraw multiple pages of text every frame, so it's not nearly so exciting in practice unfortunately. I've got a couple more PRs to come though, everything together should add up to a nice improvement.

ickshonpe avatar Dec 03 '25 23:12 ickshonpe