Skip to content

"Always Strong" Asset Handles / Remove asset weak handles #19024

Open
@andriyDev

Description

@andriyDev

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-AssetsLoad files from disk to use for things like images, models, and soundsC-Code-QualityA section of code that is hard to understand or changeD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesS-Needs-DesignThis issue requires design work to think about how it would best be accomplished

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions