Massive Editor lag / performance drop while previewing Legacy Animations in Animation window inside Prefab Edit Mode from Odin with PrefabModificationHandler.Update

Issue #659 new
Chris Lewis created an issue

To reproduce: Create an Prefab some scripts drawn with Odin. Add an Animation component, create an AnimationClip for this component. Open the Prefab in Prefab Edit Mode and preview the animation using the Animation Window:

See setup:

In this case I have two simple scripts that are drawn by Odin, nothing fancy inside of them. When previewing the animation editor performance is terrible, but if I minimize these components views in the Inspector Window - performance recovers.

Deep Profile results point to a lot of work done by Odin due to PrefabUtility.GetPropertyModifications():

See chain below:

Comments (6)

  1. Tor Esa Vestergaard

    Hmm, this would appear to be a performance issue in Unity itself. Odin has to call that method to be able to support drawing Unity’s prefab instance modifications properly. You should report this issue to Unity, because calling that method shouldn’t be anything like that expensive.

  2. Chris Lewis reporter

    Well, If I disable Odin with the ‘Enable Odin In Inspector’ toggle:

    The issue isn’t observed.

  3. Tor Esa Vestergaard

    Yes, Unity has their own internals to handle this that Odin does not have access to; instead we must use the public API that they provide to interact with the prefab modification system.

  4. Chris Lewis reporter

    During animation preview it ends up changing the variables that are animating every frame. However these are not real changes to the transform to be serialized to the Prefab, merely animation previews. Is there a way to discern this and prevent the work it’s doing? Or is the Unity API simply not exposing enough?

  5. Tor Esa Vestergaard

    To my knowledge, at least, the way we currently do it (calling GetPropertyModifications constantly) is the only way we can get the information we need to correctly display Unity’s modifications in the inspector. We used to try to be clever about calling it less often, and that caused so many impossible issues and had so many edge cases that we hadn’t predicted, that we went back to calling it all the time.

  6. Chris Lewis reporter

    Okay gotcha, the workaround for me is just minimizing the display of those two scripts while doing any animation preview which is fine. 🙂

  7. Log in to comment