Option::unwrap panic in `specialize_material2d_meshes`
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## Bevy version
0.16
## \[Optional\] Relevant system information
Does not seem relevant, but happy to provide extra info if needed.
## What you did
Code worked fine on 0.15, but starts crashing on 0.16. I don't have a small reproducer readily available unfortunately, but I can potentially look into that at a later time if needed.
## What went wrong
My application crashes on a `unwrap` call in `specialize_material2d_meshes` deep in the bevy internals.
```
thread 'Compute Task Pool (23)' panicked at ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_sprite-0.16.0/src/mesh2d/material.rs:730:79:
called `Option::unwrap()` on a `None` value
stack backtrace:
0: rust_begin_unwind
at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/std/src/panicking.rs:692:5
1: core::panicking::panic_fmt
at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/core/src/panicking.rs:75:14
2: core::panicking::panic
at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/core/src/panicking.rs:145:5
3: core::option::unwrap_failed
at /rustc/4d91de4e48198da2e33413efdcd9cd2cc0c46688/library/core/src/option.rs:2015:5
4: core::option::Option::unwrap
at ~/.rustup/toolchains/1.85.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/option.rs:978:21
5: bevy_sprite::mesh2d::material::specialize_material2d_meshes
at ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_sprite-0.16.0/src/mesh2d/material.rs:730:79
6: core::ops::function::FnMut::call_mut
at ~/.rustup/toolchains/1.85.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:166:5
7: core::ops::function::impls:: for &mut F>::call_mut
at ~/.rustup/toolchains/1.85.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:294:13
8: Out>>::run::call_inner
at ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_ecs-0.16.0/src/system/function_system.rs:945:21
9: Out>>::run
at ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_ecs-0.16.0/src/system/function_system.rs:948:17
10: as bevy_ecs::system::system::System>::run_unsafe
at ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_ecs-0.16.0/src/system/function_system.rs:735:19
11: as bevy_ecs::system::system::System>::run_unsafe
at ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_ecs-0.16.0/src/system/schedule_system.rs:64:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Encountered a panic in system `bevy_sprite::mesh2d::material::specialize_material2d_meshes`!
```
## Additional information
I've seen https://github.com/bevyengine/bevy/issues/18980 so far, which seems to have an unwrap crash in the 3D variant of mesh material specialization, perhaps that's related?
Contributor guide
Research direction
Start with bevy_sprite-0.16.0/src/mesh2d/material.rs at line 730 and inspect specialize_material2d_meshes where the Option::unwrap panic occurs. Compare the 2D failure with the related 3D specialization crash in issue 18980. Done means the reported application path no longer panics, but a small reproducer is still needed to verify the fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- computer-graphics, game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100