Search Unity

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

Discussion in 'Editor & General Support' started by pastaluego, Oct 23, 2018.

  1. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    upload_2018-10-23_16-15-8.png

    *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.
     
    alexeyzakharov likes this.
  2. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    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.
     
    Last edited: Oct 24, 2018
  3. alexeyzakharov

    alexeyzakharov

    Joined:
    Jul 2, 2014
    Posts:
    507
    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.
     
    Lars-Steenhoff likes this.
  4. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    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.
     
  5. alexeyzakharov

    alexeyzakharov

    Joined:
    Jul 2, 2014
    Posts:
    507
    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.
     
    pastaluego and Lars-Steenhoff like this.
  6. alexeyzakharov

    alexeyzakharov

    Joined:
    Jul 2, 2014
    Posts:
    507
    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!
     
    5argon and pastaluego like this.