LoadContext.get_handle() returns invalid or dropped handles
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## Bevy version
0.6.1
## Operating system & version
Windows 10
## What you did
1. Create a custom `AssetLoader`
2. Create sub-asset resources, such as `StandardMaterial`s, and save them to the current `LoadContext` via `load_context.set_labeled_asset(label, LoadedAsset::new(asset))`
3. Reference these sub-asset resources via `let path = AssetPath::new_ref(load_context.path(), Some(label))`
4. Get a handle to the resource at the path `load_context.get_handle(path)`
5. Spawn entities with these handles
Repro documented in https://github.com/agg23/bevy_loadcontext_example
## What you expected to happen
With the bug repro code above, we would expect to see a 10x10 grid of cubes of various colors (`StandardMaterial`s) every time the program is run:

## What actually happened
However, this complete grid appears rarely, and most of the time, many materials don't render:

Inspecting using `bevy_editor_pls` shows the entities as we'd expect, but the material handles don't resolve to anything:

Contributor guide
Research direction
Start with the linked bevy_loadcontext_example and trace the custom AssetLoader flow through LoadContext.set_labeled_asset, AssetPath::new_ref, and LoadContext.get_handle. Reproduce the issue on Bevy 0.6.1 and verify that spawned entities consistently resolve their StandardMaterial handles and render the complete grid.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100