bevy icon indicating copy to clipboard operation
bevy copied to clipboard

LoadContext.get_handle() returns invalid or dropped handles

Open agg23 opened this issue 2 years ago • 1 comments

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 StandardMaterials, 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 (StandardMaterials) every time the program is run:

bevy_test_2022-03-30_15-51-14

What actually happened

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

bevy_test_2022-03-30_15-51-25

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

bevy_test_2022-03-30_15-51-33

agg23 avatar Mar 30 '22 23:03 agg23