Search Issue Tracker
Fixed
Fixed in 2021.3.32f1, 2022.3.12f1, 2023.2.0b15, 2023.3.0a10
Votes
2
Found in
2021.3.31f1
2022.3.10f1
2023.2.0b10
2023.3.0a1
Issue ID
UUM-44220
Regression
No
Custom PropertyDrawers are not being released
Add the following script to a project:
{code:java}
using System;
using UnityEditor;
using UnityEngine;
[Serializable]
public class MyClass
{
}
[CustomPropertyDrawer(typeof(MyClass))]
public class MyClassDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
GUI.Label(position, label);
}
public MyClassDrawer() => Debug.Log("MyClassDrawer");
~MyClassDrawer() => Debug.Log("~MyClassDrawer");
}
public class Test : MonoBehaviour
{
public MyClass myClass = new MyClass();
}
{code}
# Add the Test component to a GameObject
# Select the GameObject, notice the property drawer is created.
# Deselect and reselect. A new drawer is created every time but the finalizer/destructor is never called.
# Enter playmode or change a script. All the finalizers are called.
It seems that something is holding onto the property drawer and preventing them from being garbage collected. This makes it hard to clean up after a drawer and results in issues such as this [https://forum.unity.com/threads/application-shutdown-cleanupmono-never-finishes.1118140/page-2#post-9171365]
From what I can see, the drawer is stored in *Editor.propertyHandlerCache* however when the Editor is released (OnDisable etc) the drawer is still not released, even if you force propertyHandlerCache to null. It appears that it is being referenced somewhere.
Tested on 2019.4, 2021.3 and 2023.3. They all have the issue.
Calling UnloadUnsedAssets and GC.Collect does not help.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- “[Worker0] Could not generate preview image“ error when opening macOS native plugin in the Inspector with Architecture to build for set to ARM 64-bit
- [iOS] Application.absoluteURL is empty on Awake/Start when opening via deep link with Splash Screen disabled
- Crash on MemoryManager::Deallocate when rapidly calling Addressables.LoadAssetAsync
- Crash on physx::shdfnd::atomicIncrement when adjusting values on a character controller component after entering Play mode in Prefab edit mode
- [Rendering Debugger] [NewInputSystem] Debug Overlays in Play mode throws InvalidOperationException when using New Input System
Add comment