Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. The 2023.1 beta is now available for testing. To find out what's new, have a look at our 2023.1 feature highlights.
    Dismiss Notice

Why PlayerLoop are call 3 times when i run an empty project ?

Discussion in 'Profiler Previews' started by firatyasin0233, Oct 7, 2021.

  1. firatyasin0233

    firatyasin0233

    Joined:
    Jul 28, 2021
    Posts:
    2
    Hello,

    When I run an empty project and check Profiler, PlayerLoop and Editor are called 3 times. However, when I check Profiler of an old project, PlayerLoop and Editor are called 1 time. What is the reason for this and will this cause any problems in terms of optimization?

    upload_2021-10-7_7-54-23.png

    Note : I use Unity3D version 2020.3.19f1(LTS) or 2020.3.16f1(LTS)
     
  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    1,896
    Hello,
    I'd suggest to check out Timeline view to understand what's going on there. But basically, these are three different intervals within the frame, not 3 Player/Editor loops. Each interval does a set of work, before handing back over to the Editor/Player loop to do it's corresponding thing within the frame.

    Simply put, no.

    The more complex truth is that the Playmode within the Editor always behaved differently to the Player and that this intermix of work with the editor has always made it a bit trickier to analyze Render Thread and GPU boundness. In fact, before 2020.1 the Stats display in the Game view has ignored the EditorLoop in it's FPS calculation, suggesting that the player would run at this frame rate if it weren't for the Editor. That was always very fuzzy math, as a Render Thread, VSync or GPU bound game would behave quite differently in a Standalone frame rate wise, in some cases prompting users to report a lower frame rate in their build compared to in the Editor, thinking it had to be a bug.

    So the fact that the Player is running in intertwined lockstep with the Editor DOES make optimizing for a build by looking at the performance data of a Playmode run a bit tricky, but that's always been the case. The golden rule is: profile on your target platform first to see what and where the problems lie, then use Playmode profiling while iterating on a possible solution, lastly verify that solution on device again.

    Sidenote: there was a bug once on Mac where the full Player loop was executing the same frame intervals twice in one Editor frame, causing a regression in performance. That's a separate thing and should be quite apparent not to be the case when looking at Timeline view.
     
    firatyasin0233 likes this.
  3. firatyasin0233

    firatyasin0233

    Joined:
    Jul 28, 2021
    Posts:
    2
    It was pretty self explanatory and I'm relieved :) Thank you for answering my question.

    Best regards,
     
    MartinTilo likes this.
  4. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    1,896
    Happy to help :)
     
    firatyasin0233 likes this.