From 6a06e0a6571d0e11c75fc440a7909ec6164eb27d Mon Sep 17 00:00:00 2001 From: charlotte Date: Mon, 14 Apr 2025 18:57:53 -0700 Subject: [PATCH] Revert attempt to fix memory leak (#18845) This reverts commit a9b0b4e7f7a51db77df0ca75c7029d7b60daa369. --- crates/bevy_render/src/render_asset.rs | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/crates/bevy_render/src/render_asset.rs b/crates/bevy_render/src/render_asset.rs index 0568b40391..6626cb7797 100644 --- a/crates/bevy_render/src/render_asset.rs +++ b/crates/bevy_render/src/render_asset.rs @@ -246,6 +246,10 @@ pub(crate) fn extract_render_asset( let mut modified = >::default(); for event in events.read() { + #[expect( + clippy::match_same_arms, + reason = "LoadedWithDependencies is marked as a TODO, so it's likely this will no longer lint soon." + )] match event { AssetEvent::Added { id } => { needs_extracting.insert(*id); @@ -254,20 +258,9 @@ pub(crate) fn extract_render_asset( needs_extracting.insert(*id); modified.insert(*id); } - AssetEvent::Removed { id, .. } => { - // Normally, we consider an asset removed from the render world only - // when it's final handle is dropped triggering an `AssetEvent::Unused` - // event. However, removal without unused can happen when the asset - // is explicitly removed from the asset server and re-added by the user. - // We mark the asset as modified in this case to ensure that - // any necessary render world bookkeeping still runs. - - // TODO: consider removing this check and just emitting Unused after - // Removed to ensure that the asset is always "really" removed from the - // render world when the last strong handle is dropped. - if !removed.contains(id) { - modified.insert(*id); - } + AssetEvent::Removed { .. } => { + // We don't care that the asset was removed from Assets in the main world. + // An asset is only removed from RenderAssets when its last handle is dropped (AssetEvent::Unused). } AssetEvent::Unused { id } => { needs_extracting.remove(id);