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

Panic on custom UiMaterial using a texture not loaded yet #10513

Closed
djeedai opened this issue Nov 11, 2023 · 4 comments · Fixed by #10591
Closed

Panic on custom UiMaterial using a texture not loaded yet #10513

djeedai opened this issue Nov 11, 2023 · 4 comments · Fixed by #10591
Labels
A-Rendering Drawing game state to the screen A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior
Milestone

Comments

@djeedai
Copy link
Contributor

djeedai commented Nov 11, 2023

Bevy version

0.12

What you did

Follow the docs for UiMaterial, using an image texture.

What went wrong

Panic:

  13:     0x7ff6ecaef015 - bevy_ui::render::ui_material_pipeline::queue_ui_material_nodes<my_project::ui::UiGrayscaleFilterMaterial>
                               at C:\Users\<user>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_ui-0.12.0\src\render\ui_material_pipeline.rs:730

Additional information

  • extract_ui_material_nodes doesn't look at texture loading
  • queue_ui_material_nodes does an unwrap() on the RenderUiMaterials<M>
  • I suspect the custom material is only inserted in RenderUiMaterials<M> by prepare_ui_materials once the image is actually loaded
  • The example/ui/ui_material.rs doesn't use an image so we don't have coverage for that case I think
@djeedai djeedai added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen A-UI Graphical user interfaces, styles, layouts, and widgets labels Nov 11, 2023
@djeedai
Copy link
Contributor Author

djeedai commented Nov 11, 2023

Debugged, this is AsBindGroup::as_bind_group() failing on first frame, because Self::unprepared_bind_group() returns AsBindGroupError::RetryNextUpdate. I can't really find the relevant derive code but I suspect the derive waits for the image to be loaded.

@JMS55 JMS55 added this to the 0.12.1 milestone Nov 12, 2023
@cart
Copy link
Member

cart commented Nov 16, 2023

@MarkusTheOrt

@MarkusTheOrt
Copy link
Contributor

I’ll take a look as soon as I can. I currently have computer problems that I hope to have fixed by tomorrow.

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

- Fix the panic on using Images in UiMaterials due to assets not being
loaded.
- Fixes #10513 

## Solution

- add `let else` statement that `return`s or `continue`s instead of
unwrapping, causing a panic.
@djeedai
Copy link
Contributor Author

djeedai commented Nov 17, 2023

Thanks @MarkusTheOrt !

cart pushed a commit that referenced this issue Nov 30, 2023
# Objective

- Fix the panic on using Images in UiMaterials due to assets not being
loaded.
- Fixes #10513 

## Solution

- add `let else` statement that `return`s or `continue`s instead of
unwrapping, causing a panic.
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this issue Jan 9, 2024
# Objective

- Fix the panic on using Images in UiMaterials due to assets not being
loaded.
- Fixes bevyengine#10513 

## Solution

- add `let else` statement that `return`s or `continue`s instead of
unwrapping, causing a panic.
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 A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants