Search Unity

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

Bug Editor loop high thread utilization on play mode

Discussion in '2020.1 Beta' started by Roldo, May 28, 2020.

  1. Roldo

    Roldo

    Joined:
    Oct 25, 2014
    Posts:
    41
    Hello

    I have created a small test project to see how unity 2020.1 beta will work with my current plugins and on entering play mode, unity starts to lag very badly(clicks registering after ~10 sec)

    The external packages i use(asset store previously) are:
    • Odin Inspector
    • Json .NET (.dll in the packages folder)
    From preview packages i use the 2d Extras package.
    I dont have any OnUpdate code and only one GameObject that has an OnStart method that draws a test shape on a Tilemap.

    What could've caused the issue? My guess was that it was Odin, however when i loaded an empty project without Odin(and default manifest.json) the issue remained.
    These are the contents of my default Packages/manifest.json file:

    Code (Json):
    1. {
    2.   "dependencies": {
    3.     "com.unity.collab-proxy": "1.3.7",
    4.     "com.unity.ide.rider": "1.2.1",
    5.     "com.unity.ide.visualstudio": "2.0.1",
    6.     "com.unity.ide.vscode": "1.2.0",
    7.     "com.unity.test-framework": "1.1.13",
    8.     "com.unity.textmeshpro": "3.0.0-preview.1",
    9.     "com.unity.timeline": "1.3.2",
    10.     "com.unity.ugui": "1.0.0",
    11.     "com.unity.modules.ai": "1.0.0",
    12.     "com.unity.modules.androidjni": "1.0.0",
    13.     "com.unity.modules.animation": "1.0.0",
    14.     "com.unity.modules.assetbundle": "1.0.0",
    15.     "com.unity.modules.audio": "1.0.0",
    16.     "com.unity.modules.cloth": "1.0.0",
    17.     "com.unity.modules.director": "1.0.0",
    18.     "com.unity.modules.imageconversion": "1.0.0",
    19.     "com.unity.modules.imgui": "1.0.0",
    20.     "com.unity.modules.jsonserialize": "1.0.0",
    21.     "com.unity.modules.particlesystem": "1.0.0",
    22.     "com.unity.modules.physics": "1.0.0",
    23.     "com.unity.modules.physics2d": "1.0.0",
    24.     "com.unity.modules.screencapture": "1.0.0",
    25.     "com.unity.modules.terrain": "1.0.0",
    26.     "com.unity.modules.terrainphysics": "1.0.0",
    27.     "com.unity.modules.tilemap": "1.0.0",
    28.     "com.unity.modules.ui": "1.0.0",
    29.     "com.unity.modules.uielements": "1.0.0",
    30.     "com.unity.modules.umbra": "1.0.0",
    31.     "com.unity.modules.unityanalytics": "1.0.0",
    32.     "com.unity.modules.unitywebrequest": "1.0.0",
    33.     "com.unity.modules.unitywebrequestassetbundle": "1.0.0",
    34.     "com.unity.modules.unitywebrequestaudio": "1.0.0",
    35.     "com.unity.modules.unitywebrequesttexture": "1.0.0",
    36.     "com.unity.modules.unitywebrequestwww": "1.0.0",
    37.     "com.unity.modules.vehicles": "1.0.0",
    38.     "com.unity.modules.video": "1.0.0",
    39.     "com.unity.modules.vr": "1.0.0",
    40.     "com.unity.modules.wind": "1.0.0",
    41.     "com.unity.modules.xr": "1.0.0"
    42.   }
    43. }

    EDIT:
    I have tested the same projects in earlier versions of unity and such issue only appears in 2020.1 beta

    EDIT 2:
    I have tested the issue with unity 2020.1.0b10 and the issue is still present
     
    Last edited: May 29, 2020
    alexeyzakharov likes this.
  2. Roldo

    Roldo

    Joined:
    Oct 25, 2014
    Posts:
    41
    So, for troubleshooting i have uninstalled all beta unity versions i have and reinstalled 2020.1.0b10 on C drive.
    After that i have loaded a new blank project and used profiler to see thread utilization.

    Turns out that right after entering play mode, EditorLop spikes up to ~200ms and stays there for some time.
    Annotation 2020-05-28 224411.png
    After some time, however it calms down and unity resumes to working as normal(without staying at 200-300ms cpu utilization), however it it literally unbearable as it takes about a minute to recover(each frame takes about 300ms to execute after all)

    I am not using any external plugins and the project is blank(contains only camera and directional light.)
    This is the profiler output saved ~300 frames in after entering play mode.

    Such issue is not present on the 2019 version of unity
     
  3. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,571
    Have you checked what inside "EditorLoop" causes this?
    1. Open Profiler window
    2. Switch from "Timeline" to "Hierarchy" in the Profiler
    3. Change drop-down from "Playmode" to "Editor"
    4. Enable "Record"
    5. Press Play
    If you then expand the "EditorLoop" node in the Profiler all the way down, it should reveal what those 300ms causes.
     
  4. Roldo

    Roldo

    Joined:
    Oct 25, 2014
    Posts:
    41
    Thanks for pointing that out, i have done so and turns out that the part of editor loop that causes the 300ms utilization is TickSceneTracker
    Annotation 2020-05-28 233603.png
    After some time running i also got a fatal GC error after which unity crashed.

    I suppose that these are related, as the GC error only happens in the beta version after some time has passed.
    My guess is that something in the TickSceneTracker causes a memory leak, causing garbage collection to work way to hard each frame thus causing the utilization to spike. This is just a guess though.
     
  5. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,571
    Can you continue to expand the first item of the "top cost". In this case please expand "EditorApplication.Internal_CallUpdateFunction" and then expand the first child of this one and so on. It should occasionally show where the actual cost comes from.

    Like shown in this post.
     
  6. Roldo

    Roldo

    Joined:
    Oct 25, 2014
    Posts:
    41
    This is the "high cost" part of the EditorLoop tree Annotation 2020-05-29 002334.png
     
  7. Roldo

    Roldo

    Joined:
    Oct 25, 2014
    Posts:
    41
    Any ideas how to solve the problem?
     
  8. Roldo

    Roldo

    Joined:
    Oct 25, 2014
    Posts:
    41
    I have tried removing different packages through package manager and changing my layout to only contain scene view, hierarchy and information and the issue is still present.
    Profiler does not show anything particluar that i can see, only TickSceneTracker -> <CallDelayed>
     
  9. Roldo

    Roldo

    Joined:
    Oct 25, 2014
    Posts:
    41
    Found out that resetting the layout fixes the issue. No idea still what couldve caused it, as my layout didnt contain anything more than standard ui elements
     
    valentingurkov likes this.
  10. valentingurkov

    valentingurkov

    Joined:
    Jun 17, 2019
    Posts:
    13
    Can confirm. Updated test project playground from 2019.3 to 2020.1.0b11 and when entering play mode I got 3-5 FPS instead of 350-400. Editor Loop was trough the roof in the profiler. After I read your comment I did a reset of my layout (which was pretty much default + a few extra tabs) and everything is back to normal performance-wise.

    No idea what caused it though..
     
  11. jonathans42

    jonathans42

    Unity Technologies

    Joined:
    Jan 25, 2018
    Posts:
    514
    Hi, I believe this issue has been fixed with 2020.2.0a14
     
  12. Dynam1ke

    Dynam1ke

    Joined:
    Jun 9, 2014
    Posts:
    4
    Using 2021.3.13f1 I am having the same issue.