Open akien-mga opened 2 months ago
This is likely another multi threaded loading issue.
Setting threading/worker_pool/max_threads
to 1
should be enough to avoid the assert, but it will also increase loading time significantly and may increase frame time as well.
I think I tried that and it didn't resolved the assert. But I'll test again tomorrow to confirm. Note that this happens in the editor, not at runtime
Edit: Tested, I confirmed that even with threading/worker_pool/max_threads
set to 1
, the editor crashes on exit.
The list that contains an element when it shouldn't (at engine shutdown) is MaterialStorage::material_update_list
. In normal circumstances, at that point all the materials would have been unregistered so it would be empty. That's true even if the last frame before shutdown adds some materials to that list because of broken dependency chains (e.g., a texture is released so a uniform set is freed so a callback is run to update the material). If that happens (which is only natural), the updates are added to the list, but, even if the list is not processed anymore, as the materials are eventually destroyed, they are removed from the list.
However, in this project, by the time MaterialStorage
is being destroyed (quite later in engine shutdown), there are still some cached resources around, including a scene (res://scenes/combat/ui/damage_number.tscn
) that happens to contain a ParticlesProcessMaterial
subresource. That resource happens to be the only one in the material_update_list
. It seems that the project (maybe some of its plugins) is creating a circle of references preventing certain resources from being released.
It's interesting that, in a case like this, a vicious circle of dependencies is not only causing memory leaks but an ill situation where the material exists at a point where it shoudn't be possible and even scripts are kept in memory once the GDScript engine has been terminated.
The error message itself could be silenced by explicitly clearing the list before its destructor runs. However, being a dev-only check, I believe it's better not to fight the warning, as that'd be fighting the symptom without curing the illness. That said, it depends on what's the rule here: if the engine is supposed to allow projects to leak resources gracefully, then the explicit clear should be added.
Tested versions
System information
Fedora Linux 40 (KDE Plasma) - Wayland - Vulkan (Forward+) - dedicated AMD Radeon RX 7600M XT (RADV NAVI33) - AMD Ryzen 7 7840HS w/ Radeon 780M Graphics (16 Threads)
Issue description
Upon closing the editor with a medium sized project using GPUParticles (W4's Legend of the Nuku Warriors demo, not public yet), I get this dev assert (in a
dev_build=yes
build):Steps to reproduce
TBD, load project that creates a ParticlesShaderRD in the editor, and close the editor.
Minimal reproduction project (MRP)
Not tried to extract one yet, but @clayjohn @RandomShaper @DarioSamo have access to the project where I can reproduce this.