Multiple load_untyped requests for the same labeled asset can result in duplicate asset loads
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## Bevy version
0.12.0
## What went wrong
As of #10514, load_untyped / load_untyped_async will defer handle creation for labeled assets until after the asset loads, as we cannot know the type ahead of time (unless it is provided manually).
This means that loading a labeled untyped asset multiple times won't always "early out" for duplicate asset loads. If a second duplicate request for a labeled untyped asset is made before the labeled asset handle is allocated in the AssetLoader, a second load of the root asset will occur.
This isn't broken, but it is suboptimal / undesirable behavior. I'm not sure we can fix this without changing how handles work.
Notably, I think moving to "assets as entities" (or an equivalent "universal id with indirection" system) resolves this problem because you no longer need to know the type to allocate an identifier. This would also allow us to "de-async-ify" untyped asset loading, which is one of the pain points people are experiencing with Bevy Asset V2.
Contributor guide
Research direction
Start by tracing load_untyped and load_untyped_async through the AssetLoader, focusing on when handles for labeled assets are allocated and how duplicate root loads are triggered. Compare the current handle behavior with the proposed assets-as-entities or universal-id approach; done means duplicate labeled requests no longer initiate redundant root asset loads without regressing typed or untyped loading.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev, performance
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100