Closed MPierer closed 5 months ago
Thanks for reporting!
However, I can not reproduce it with the following setup on 2.1.9:
Rate
, and ensure the stars are displayed on the inspector. Click ReadOnly
to un-active Rate
. The Console didn't give any message.Window
- Saints
- Disable UI Toolkit Support
, wait, and do step 3 again. Still the same.Please give the following information of how I can re-produce the env as you do to check the issue:
f1
so it's the full version I can check, and if it's f1c1
that means it's Chinese special edition)BTW, thanks for the information you provide that says the following:
Note: This is called by the GC; and not necessarily on inspector selection change.
So indeed there IS an issue when SaintsField:
// RichLabelAttributeDrawer.cs
~RichLabelAttributeDrawer()
{
_richTextDrawer.Dispose();
}
// RichTextDrawer.cs
public void Dispose()
{
foreach (Texture cacheValue in _textureCache.Values)
{
UnityEngine.Object.Destroy(cacheValue); // Yep, this should be the problem if Unity disallow Texture2D release on a GC calling...
}
_textureCache.Clear();
}
I'll see if there is a better option for SaintsField
to handle this.
Thanks for your comments and sorry for not being very precise in my report. It's in Unity 2022.3.10f1, but happens in 2020.3.48f1 as well. The exception is only caught in Debugger (Rider or Visual Studio), it won't be displayed in the normal console. Make sure the Debugger is set to catch exceptions. When the exceptions is thrown the calls to Destroy the Unity Textures (in RichTextDrawer.Dispose for example) won't have any effect and memory will be leaked.
Using Package 2.1.9 and Unity 2022.3 (same with 2021) I get an exception in the Example scene when selection changes, while debugging a project.
The SaintsPropertyDrawers get instantiated by Unity on the main thread, but get delected by the Garbage Collector on the GC Thread. So I guess when the exception is thrown there is also a mem leak following. This will happen for other Drawers as well, like the Rate drawer, which needs to dispose Texture2Ds. Not sure what might be the best solution: either scheduling these Dispose calls on the main thread (like https://github.com/StansAssets/com.stansassets.foundation/tree/master/Runtime/Async/MainThreadDispatcher ) or listening to Selection Changed event and call sth. like "Disable" on the property drawers (see: https://discussions.unity.com/t/onenable-disable-on-property-drawers/117700/5 )