bevy/crates
Carter Anderson 9ac0d9b50d Allow removing and reloading assets with live handles (#10785)
# Objective

Fixes #10444 

Currently manually removing an asset prevents it from being reloaded
while there are still active handles. Doing so will result in a panic,
because the storage entry has been marked as "empty / None" but the ID
is still assumed to be active by the asset server.

Patterns like `images.remove() -> asset_server.reload()` and
`images.remove() -> images.insert()` would fail if the handle was still
alive.

## Solution

Most of the groundwork for this was already laid in Bevy Asset V2. This
is largely just a matter of splitting out `remove` into two separate
operations:

* `remove_dropped`: remove the stored asset, invalidate the internal
Assets entry (preventing future insertions with the old id), and recycle
the id
* `remove_still_alive`: remove the stored asset, but leave the entry
otherwise untouched (and dont recycle the id).

`remove_still_alive` and `insert` can be called any number of times (in
any order) for an id until `remove_dropped` has been called, which will
invalidate the id.

From a user-facing perspective, there are no API changes and this is non
breaking. The public `Assets::remove` will internally call
`remove_still_alive`. `remove_dropped` can only be called by the
internal "handle management" system.

---

## Changelog

- Fix a bug preventing `Assets::remove` from blocking future inserts for
a specific `AssetIndex`.
2023-11-29 17:06:03 -08:00
..
bevy_a11y Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_animation Fix animations resetting after repeat count (#10540) 2023-11-29 16:42:51 -08:00
bevy_app Wait until FixedUpdate can see events before dropping them (#10077) 2023-11-29 16:55:21 -08:00
bevy_asset Allow removing and reloading assets with live handles (#10785) 2023-11-29 17:06:03 -08:00
bevy_audio Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_core Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_core_pipeline Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_derive Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_diagnostic Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_dylib Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_dynamic_plugin Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_ecs fix insert_reflect panic caused by clone_value (#10627) 2023-11-29 17:02:53 -08:00
bevy_ecs_compile_fail_tests Updates for rust 1.73 (#10035) 2023-10-06 00:31:10 +00:00
bevy_encase_derive Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_gilrs Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_gizmos Fix float precision issue in the gizmo shader (#10408) 2023-11-29 16:44:26 -08:00
bevy_gltf Fix GLTF scene dependencies and make full scene renders predictable (#10745) 2023-11-29 17:02:28 -08:00
bevy_hierarchy Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_input Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_internal Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_log Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_macro_utils Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_macros_compile_fail_tests bevy_derive: Fix #[deref] breaking other attributes (#9551) 2023-08-28 17:36:18 +00:00
bevy_math Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_mikktspace Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_pbr Ensure instance_index push constant is always used in prepass.wgsl (#10706) 2023-11-29 17:03:03 -08:00
bevy_ptr Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_reflect Fix nested generics in Reflect derive (#10791) 2023-11-29 17:03:36 -08:00
bevy_reflect_compile_fail_tests Fix nested generics in Reflect derive (#10791) 2023-11-29 17:03:36 -08:00
bevy_render try_insert Aabbs (#10801) 2023-11-29 17:05:25 -08:00
bevy_scene Use handles for queued scenes in SceneSpawner (#10619) 2023-11-29 16:52:11 -08:00
bevy_sprite try_insert Aabbs (#10801) 2023-11-29 17:05:25 -08:00
bevy_tasks Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_text Improved Text Rendering (#10537) 2023-11-29 16:44:14 -08:00
bevy_time Wait until FixedUpdate can see events before dropping them (#10077) 2023-11-29 16:55:21 -08:00
bevy_transform Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_ui Fix typo in resolve_outlines_system (#10730) 2023-11-29 16:53:56 -08:00
bevy_utils Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_window Release 0.12 (#10362) 2023-11-04 17:24:23 +00:00
bevy_winit don't run update before window creation in winit (#10741) 2023-11-29 16:54:08 -08:00