Performance Issues on OnInspectorGUI when in a large scene even when viewing simple objects.

Issue #684 open
Ryan Murphy created an issue

Odin: 2.1.12

Unity: 2019.4.5f1

Editor only mode is not enabled.

OSX 10.15.4

I have been experiencing massive editor lag which seems to be caused by Odin. To narrow it down I disabled Odin drawing for all components via Odin > Preferences > Editor Types.

With all drawing off a frame takes ~3ms as viewed in the Profiler. With a single simple component set to draw with Odin a frame takes ~240 ms to run. Below is the structure of the component.

public class DisplayableUIController : MonoBehaviour
{
    public TMP_Text TitleText;
    public TMP_Text TypeText;
    public TMP_Text DescriptionText;
    public Image Icon;
    public Image IconReward;
    public Image IconBackgroundLayer;
    public Image IconBackgroundLayerReward;

    public Sprite DefaultIcon;
    public Sprite DefaultIconBackgroundLayer;
    public String DefaultText;
}

I toggle drawing of that controller off and the performance immediately goes back to ~3ms a frame. Stepping through almost all time is in the OnInspectorGUI for this component.

I have tested this with ~20 other components in my game all with the same results.

To be clear this is all in Editor, not in Play mode. Attached is a screenshot of a profiler capture

Important notes:

  1. This scene has a lot of UI with LayoutGroups and many instanced prefabs that cause frequent phantom changes caused by Unity
  2. I do not see this behavior when I view a prefab in the prefab sandbox view. I suspect that is because of less changes caused by 1 above.

The scene in question is a large UI Scene. ~50 nested prefabs, likely well over 1000 objects.

Does Odin do something when it renders a given object that scans the whole scene?

Comments (5)

  1. Ryan Murphy reporter

    Another data point. I created an empty scene.

    1. I created an Empty Scene.
    2. I created a new Empty game object.
    3. Added the component above.
    4. Enabled Odin drawing of the component.

      1. Saw the massive performance hit
    5. I disabled the game object, and reenabled it and draw performance was fine. This was all while Odin was drawing on that component was turned on.

      1. I also did a similar

    This seems to be slightly inconsistent. Sometimes I can just click in the inspector window a few times and it will resolve. It seems to be completely dependent on how many times Unity wants to call the OnInspectorGUI path.

    As another point of clarity. This is my a 5 person team all seeing these issues.

  2. Tor Esa Vestergaard
    • changed status to open

    Hmm, this one is hard to pinpoint without a better idea of exactly where all the time is going inside of the Odin drawing. It could truly be many different things. If you have a reproduction project I can test out and profile myself, that would be lovely. Otherwise, I would need to rely on your to step more deeply into the profiler view and determine which parts of Odin are causing this performance issue.

    Odin 3.0 also brings many performance improvements with it. If you could download the latest beta and give it a shot there to see how performance has changed, that would be great. We have resolved many performance issues and performed a lot of optimizations with 3.0 - it is possible that we have done something which affects this specific case.

  3. Ryan Murphy reporter

    Unfortunately, that's as deep in the tree went. Below that was just a GCAlloc with no self-time. Allocations did seem high. I just tried to repro but I implemented a workaround where extended Monobehaviour and added a toggle to be able to turn on Odin rendering when we need it so with that I can’t easily get into the state anymore. I will try the Beta as soon as I can. Probably later this week.

  4. Log in to comment