"Always Strong" Asset Handles / Remove asset weak handles
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## What problem does this solve or what need does it fill?
Today, all main user APIs for accessing assets use Handles. Handles come in two flavors: strong handles which keep the asset from being removed, and weak handles which don't keep the asset from being removed. Weak handles are just a wrapper around the raw `AssetId`. Note that strong handles also include an `AssetId`. So it seems we are duplicating effort here (if you needed a "weak handle", why can't you just store `AssetId` directly?)
Most assets can and should be removed when all their handles are dropped. However currently there is one exception to this: UUID assets. Handles to these assets are usually defined as `const` with the `weak_handle!` macro. Since they are defined in `const`, they don't correspond to a live asset. Therefore, these must be weak handles. And these assets need to be used in user APIs, so it needs to be a `Handle`, not just an `AssetId`. This has also resulted in requiring the `Assets` resource to contain a "dense storage" for regular assets, and a "hash storage" which is just a hashmap from the UUID to the asset. This duplicate implementation is quite unfortunate!
## What solution would you like?
Remove weak handles! Stop supporting UUIDs and always use strong handles.
Contributor guide
Assessment
This issue has not been assessed yet.