Hang time when Entering Play Mode only when a GameObject (even empty) is selected.

*key note: This is the frame when entering playmode

After deep profiling the editor, I’ve narrowed down this call being what I think is the culprit.
175k calls of that when entering playmode seems super wrong.
I think it may have something to do with one of my editor scripts, but it even happens if I have an empty gameobject selected. If the Inspector has nothing selected at all, then there’s no hang time when entering playmode whatsoever. So I’m super confused.

1 Like

Is there any way to find out which editor script I have that might be causing that number of calls? Since it’s an internal call, it doesn’t show which script specifically is doing it.

Hi,

Looking at the ScriptAttributeUtility it is a UnityEditor.dll class. There is nothing you can do besides reducing C# classes count in the project unfortunately.

Thanks for reporting this - ScriptAttributeUtility.BuildDrawerTypeForTypeDictionary is scanning for GUIDrawer and doing that from a managed code is crazy expensive. We are looking into optimizing that part.

1 Like

Is there a reason checking inheritance in.NET 4.x became so much slower than 3.5?
It’s just super weird how clicking an inspector after an assemblyreload even in an empty project takes 1300ms with 4.x and with 3.5 it only takes 300ms.

Yes, there was a performance regression - see https://github.com/mono/mono/issues/10000
The situation should be improved once we update mono, but for now we are working on improving hot pathsof IsSubclassOf usage in Unity codebase.

2 Likes

ScriptAttributeUtility.BuildDrawerTypeForTypeDictionary is optimized (>50x) in Unity 2019.2 (as well as a bunch of other similar usecases).
We cache attributes and derived classes information on the native side. With that on your project it should be <20ms.

Thanks for reporting the issue!

2 Likes