Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feedback EditorLoop::SceneHierarchyWindow.Paint performance

Discussion in '2020.1 Beta' started by Peter77, May 9, 2020.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,571
    Unity 2020.1.0b8:
    SceneHierarchyWindow.Paint
    continues to be the #1 performance issue for me while being in play mode. I've attached Profiler screenshots.

    I'm not sure how valuable these screenshots are to you. Please let me know whether they are helpful, because if they are not, what would be helpful to provide so you can improve performance in that area?

    SceneHierarchyWindow.Paint
    deep profile:
    upload_2020-5-9_10-4-33.png

    upload_2020-5-9_10-4-45.png

    SceneHierarchyWindow.Paint
    without deep profile:
    upload_2020-5-9_10-13-4.png
     
    Last edited: May 9, 2020
    richardkettlewell and SugoiDev like this.
  2. print_helloworld

    print_helloworld

    Joined:
    Nov 14, 2016
    Posts:
    231
    I tend to hide the hierarchy contents by collapsing the scene because of this, its a noticeable improvement. Hopefully theres some ms they can shave off the hierarchy creation/rendering logic in the future.
     
    Peter77 likes this.
  3. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    217
    Hi Peter,
    Please grab a screenshot where we can see what allocates the 1.9 KB under DoItemGUI.
     
  4. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,571
    Hi Mads,

    thanks for your interest!

    TreeViewGUI.DoItemGUI
    :
    upload_2020-5-12_13-13-41.png


    SceneHierarchy.SyncIfNeeded
    (also called every few updates):
    upload_2020-5-12_13-13-33.png
     
  5. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    217
    Ok so those two situations is expected when there has been a structural change to the transform hierarchy. The hierarchy is rebuilding it's view in SyncIfNeeded and lazy initializes and caches the name of each item on the first repaint.
    So it seems like is that something in your game logic is constantly making transform structural changes (re-parenting , sibling order changes or renaming gameobjects).
    I know that we have had an issue with transform.SetAsLastSibling() that would dirty the hierarchy state when called even if the transform is already the last sibling, a fix is coming for that. But you can search for that on your side.
    And we will look into where we can shave time off on our side.
     
  6. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,571
    Hi Mads,

    thanks again for your reply.

    Yep, that's spot on and I guess all of the three examples happen :)

    The game utilizes gameobject pooling for a lot of stuff, objects get acquired from a pool, change their parent and get renamed for debugging purposes, just to name one path where this occurs. While I could get rid of the renaming, I can't get rid of the other points.

    You seem to have an unique approach to investigate performance issues, that I would like to understand. Please excuse me if I ask the obvious.

    My approach would have been to investigate the path where most performance is being spent, that would be
    GameObjectTreeViewGUI.OnContentGUI
    with 4.5ms, but you went straight to
    GameObjectTreeViewItem.get_DisplayName
    which costs 0.25ms.

    Why did you go for the 0.25ms cost rather than the 4.5ms?
     
  7. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    217
    I was commenting on your two screenshots
     
  8. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    217
    To dig more I need your repro project. If you have submitted a case where you have attached it recently you can just refer to that here.
     
  9. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,125
    @Peter77 was your question here resolved?
     
    Peter77 likes this.
  10. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,571
    I haven't looked into the issue any further. Feel free to consider the case closed.
     
    LeonhardP likes this.
  11. DylanF

    DylanF

    Joined:
    Jun 25, 2013
    Posts:
    55
    SceneHierarchyWindow.Paint is a big pain point for me too. You can work around it by de-selecting the Hierarchy tab when in play mode. Here's an editor script that does it for you automatically.

    Put your Animation tab next to Hierarchy and Lighting next to Inspector to make it work
    Code (CSharp):
    1.  using UnityEditor;
    2. namespace UnityHacks {
    3.      [InitializeOnLoad]
    4.      public class HideExpensiveTabsDuringPlayMode {
    5.         static HideExpensiveTabsDuringPlayMode() {
    6.              EditorApplication.playModeStateChanged += HandleOnPlayModeChanged;
    7.          }
    8.          static void HandleOnPlayModeChanged(PlayModeStateChange state) {
    9.              if(state == PlayModeStateChange.ExitingEditMode) {
    10.                 EditorApplication.ExecuteMenuItem("Window/Rendering/Lighting");
    11.                 EditorApplication.ExecuteMenuItem("Window/Animation/Animation");
    12.              } else if(state == PlayModeStateChange.ExitingPlayMode) {
    13.                  EditorApplication.ExecuteMenuItem("Window/General/Inspector");
    14.                  EditorApplication.ExecuteMenuItem("Window/General/Hierarchy");
    15.              }
    16.          }
    17.      }
    18. }
     
  12. Redrag

    Redrag

    Joined:
    Apr 27, 2014
    Posts:
    178
    I am getting this in 2023.2 (not in 2023.1). Opening the hierarchy causes a massive delay (OnGUI). Also happens on turning a gameobject on/off in Inspector. This is edit not play mode.

    EDIT: I had an cloud backup running. Even through this is not backing up Unity projects it had a massive impact on this particular issue. It's funny how it affects this particular version of Unity. I do still feel 2023.2 editor seems more laggy than 2023.1.
     
    Last edited: Jan 10, 2024
  13. Yothuba

    Yothuba

    Joined:
    Oct 4, 2019
    Posts:
    21
    This is also confirmed in unity2022.3.13. In my case, the load is heavier when the objects on the timeline are in blend state, and the same is true when the Hierarchy is closed, which lightens the load.