-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
send Unused event when asset is actually unused #12459
send Unused event when asset is actually unused #12459
Conversation
this was added in #10520 to allow removing assets from the cpu side and keeping them on the gpu side |
Agreed. Different PR of course, so then we can ship this in 0.13.1.
This makes sense to me too. |
@JMS55 on discord:
i missed that so instead we can use the existing logic for processing the automatic removal (in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly just some minor style suggestions. Otherwise, makes sense!
i think the resending of |
No :) |
nope, the code is fine, sorry. i think this is good as is |
Tbh I'm having a hard time reviewing this, as the code is a bit confusing. I'm not quite sure I understand the implications of moving it around like this. |
Have a look at the related issue. the important thing is that the process_handle_drop call checks whether new handles have been created since the drop event was fired, before removing the asset. We now perform that check before sending the unused event as well. |
assets.remove_dropped(id); | ||
|
||
if !infos.process_handle_drop(untyped_id) { | ||
// a new handle has been created, or the asset doesn't exist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we expand this comment a bit with the context you put in your last comment to me? That this is a check to see if a new handle has been created in the same frame after the last one was dropped, meaning it's not actually unused.
Also, what does "or the asset doesn't exist" mean here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's what the comment in the process_handle_drop function says. i don't know a scenario where it would happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks that clears it up for me. Approved, but I'd like some more verbose doc comments.
fix #12344 use existing machinery in track_assets to determine if the asset is unused before firing Asset::Unused event ~~most extract functions use `AssetEvent::Removed` to schedule deletion of render world resources. `RenderAssetPlugin` was using `AssetEvent::Unused` instead. `Unused` fires when the last strong handle is dropped, even if a new one is created. `Removed` only fires when a new one is not created. as far as i can see, `Unused` is the same as `Removed` except for this "feature", and that it also fires early if all handles for a loading asset are dropped (`Removed` fires after the loading completes). note that in that case, processing based on `Loaded` won't have been done anyway. i think we should get rid of `Unused` completely, it is not currently used anywhere (except here, previously) and i think using it is probably always a mistake. i also am not sure why we keep loading assets that have been dropped while loading, we should probably drop the loader task as well and remove immediately.~~
Objective
fix #12344
Solution
use existing machinery in track_assets to determine if the asset is unused before firing Asset::Unused event
most extract functions use
AssetEvent::Removed
to schedule deletion of render world resources.RenderAssetPlugin
was usingAssetEvent::Unused
instead.Unused
fires when the last strong handle is dropped, even if a new one is created.Removed
only fires when a new one is not created.as far as i can see,
Unused
is the same asRemoved
except for this "feature", and that it also fires early if all handles for a loading asset are dropped (Removed
fires after the loading completes). note that in that case, processing based onLoaded
won't have been done anyway.i think we should get rid of
Unused
completely, it is not currently used anywhere (except here, previously) and i think using it is probably always a mistake.i also am not sure why we keep loading assets that have been dropped while loading, we should probably drop the loader task as well and remove immediately.