Revert attempt to fix memory leak (#18845)
This reverts commit a9b0b4e7f7
.
This commit is contained in:
parent
15ac36f6d5
commit
6a06e0a657
@ -246,6 +246,10 @@ pub(crate) fn extract_render_asset<A: RenderAsset>(
|
|||||||
let mut modified = <HashSet<_>>::default();
|
let mut modified = <HashSet<_>>::default();
|
||||||
|
|
||||||
for event in events.read() {
|
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 {
|
match event {
|
||||||
AssetEvent::Added { id } => {
|
AssetEvent::Added { id } => {
|
||||||
needs_extracting.insert(*id);
|
needs_extracting.insert(*id);
|
||||||
@ -254,20 +258,9 @@ pub(crate) fn extract_render_asset<A: RenderAsset>(
|
|||||||
needs_extracting.insert(*id);
|
needs_extracting.insert(*id);
|
||||||
modified.insert(*id);
|
modified.insert(*id);
|
||||||
}
|
}
|
||||||
AssetEvent::Removed { id, .. } => {
|
AssetEvent::Removed { .. } => {
|
||||||
// Normally, we consider an asset removed from the render world only
|
// We don't care that the asset was removed from Assets<T> in the main world.
|
||||||
// when it's final handle is dropped triggering an `AssetEvent::Unused`
|
// An asset is only removed from RenderAssets<T> when its last handle is dropped (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::Unused { id } => {
|
AssetEvent::Unused { id } => {
|
||||||
needs_extracting.remove(id);
|
needs_extracting.remove(id);
|
||||||
|
Loading…
Reference in New Issue
Block a user