Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text2d is broken #9676

Closed
rparrett opened this issue Sep 2, 2023 · 3 comments · Fixed by #10100
Closed

Text2d is broken #9676

rparrett opened this issue Sep 2, 2023 · 3 comments · Fixed by #10100
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior P-High This is particularly urgent, and deserves immediate attention
Milestone

Comments

@rparrett
Copy link
Contributor

rparrett commented Sep 2, 2023

Bevy version

main, since #9236

What you did

cargo run --example text2d

What went wrong

No text shows up.

Additional information

This is a known issue, but not yet documented here on GitHub. I'm posting here so there's a place for discussion and to point to in other issues/PRs and so that it's not forgotten.

From discord:

the queue_sprites is checking against visible_entities in order to determine whether it renders each sprite and since we are using a sparseset for sprites the text2d individual glyphs get assigned new entity ids that don't match the original Text2dBundle so they are considered not visible. Ideally we have a better way of storing text glyphs for both ui and 2d (and eventually 3d) so we don't have to spawn a bunch of empty entities.

(this doesn't currently affect UI text as it is clipped later rather than using visible_entities)

@rparrett rparrett added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen P-High This is particularly urgent, and deserves immediate attention labels Sep 2, 2023
@rparrett rparrett added this to the 0.12 milestone Sep 2, 2023
@mockersf
Copy link
Member

mockersf commented Sep 3, 2023

also example gamepad_viewer, probably for the same reasons

@rparrett
Copy link
Contributor Author

rparrett commented Sep 3, 2023

Yeah, should apply to any example utilizing Text2d:

gamepad_viewer
text_input
many_glyphs
text_pipeline
external_source_external_thread
text2d

@ickshonpe
Copy link
Contributor

For the UI I have PRs #9668 / #9212 I guess Text2d just needs something similar. The internal ordering for the glyphs of a text entity doesn't matter, the sections should be sorted by font texture and then the glyphs should be extracted in batches, one for each texture, not individually.

I've got a couple of other things I really need to finish but I'll fix this if no one else has by the end of the week or so (and if someone else wants to tackle it I'm happy to answer any questions about the text side etc).

github-merge-queue bot pushed a commit that referenced this issue Oct 13, 2023
# Objective

Fixes #9676
Possible alternative to #9708

`Text2dBundles` are not currently drawn because the render-world-only
entities for glyphs that are created in `extract_text2d_sprite` are not
tracked by the per-view `VisibleEntities`.

## Solution

Add an `Option<Entity>` to `ExtractedSprite` that keeps track of the
original entity that caused a "glyph entity" to be created.

Use that in `queue_sprites` if it exists when checking view visibility.

## Benchmarks

Quick benchmarks. Average FPS over 1500 frames.

| bench | before fps | after fps | diff |
|-|-|-|-|
|many_sprites|884.93|879.00|🟡 -0.7%|
|bevymark -- --benchmark --waves 100 --per-wave 1000 --mode
sprite|75.99|75.93|🟡 -0.1%|
|bevymark -- --benchmark --waves 50 --per-wave 1000 --mode
mesh2d|32.85|32.58|🟡 -0.8%|
ameknite pushed a commit to ameknite/bevy that referenced this issue Nov 6, 2023
# Objective

Fixes bevyengine#9676
Possible alternative to bevyengine#9708

`Text2dBundles` are not currently drawn because the render-world-only
entities for glyphs that are created in `extract_text2d_sprite` are not
tracked by the per-view `VisibleEntities`.

## Solution

Add an `Option<Entity>` to `ExtractedSprite` that keeps track of the
original entity that caused a "glyph entity" to be created.

Use that in `queue_sprites` if it exists when checking view visibility.

## Benchmarks

Quick benchmarks. Average FPS over 1500 frames.

| bench | before fps | after fps | diff |
|-|-|-|-|
|many_sprites|884.93|879.00|🟡 -0.7%|
|bevymark -- --benchmark --waves 100 --per-wave 1000 --mode
sprite|75.99|75.93|🟡 -0.1%|
|bevymark -- --benchmark --waves 50 --per-wave 1000 --mode
mesh2d|32.85|32.58|🟡 -0.8%|
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this issue Jan 9, 2024
# Objective

Fixes bevyengine#9676
Possible alternative to bevyengine#9708

`Text2dBundles` are not currently drawn because the render-world-only
entities for glyphs that are created in `extract_text2d_sprite` are not
tracked by the per-view `VisibleEntities`.

## Solution

Add an `Option<Entity>` to `ExtractedSprite` that keeps track of the
original entity that caused a "glyph entity" to be created.

Use that in `queue_sprites` if it exists when checking view visibility.

## Benchmarks

Quick benchmarks. Average FPS over 1500 frames.

| bench | before fps | after fps | diff |
|-|-|-|-|
|many_sprites|884.93|879.00|🟡 -0.7%|
|bevymark -- --benchmark --waves 100 --per-wave 1000 --mode
sprite|75.99|75.93|🟡 -0.1%|
|bevymark -- --benchmark --waves 50 --per-wave 1000 --mode
mesh2d|32.85|32.58|🟡 -0.8%|
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Bug An unexpected or incorrect behavior P-High This is particularly urgent, and deserves immediate attention
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants