Search Unity

Can someone explain to me what is happening with the fps in my project?

Discussion in 'Editor & General Support' started by Vincentin, Mar 2, 2019.

  1. Vincentin

    Vincentin

    Joined:
    Feb 4, 2017
    Posts:
    8
    Hi everyone!

    I do not know why the frames fall on my project, it's more serious when the camera looks at the ground even with less polygonal load, this happens in the editor and in build, but when I interact with anything in the editor's interface they return to normal for a while, i cant do this in build.
    In the profiler you can see a mountain range that disappears when I touch something on the interface.

    Using Unity 2018.3.6f1 and HDRP 4.10.0
    I tried to disable PostProcess, Canvas, Debug Code, Cinemachine, Lighting...

    The packages that I have installed are: Analytics Library, Cinemachine, HDRP, Package Manager, Post Processing and TextMesh Pro. All updated.

    My PC: 4790K, 1060 6Gb, 16Gb RAM.

    The escene has just one mixed directional light and a few baked ones.

     
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,790
    Don’t profile in the editor, do a build.
     
    MartinTilo likes this.
  3. Vincentin

    Vincentin

    Joined:
    Feb 4, 2017
    Posts:
    8
    In build it is less noticeable but it is still there.

     
  4. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,455
    What you are seeing is a GFX.WaitForPresent on the Main tread in those frames where performance drops. This means the Render thread couldn't finish Rendering the frame before the main thread tried to start the next frame. The Render thread seems to be in the state of "PresentFrame" in the frame just before the one with the spike, so I guess you are GPU bound but it also depends on what happened before PresentFrame and how the different timings affected each other.

    (Keep in mind, that the chart shows time on the main thread only. so while the previous frame looks ok in that chart, the render thread is running way longer than the main thread which then bleeds into the next frame as the GFX.WaitForPresent frame shows).

    So you should look at what the render thread does in the frames previous to the ones with the spike to figure out if you're doing to much pre-calculations on that thread before you send it of to the GPU (i.e. you are CPU bound) or if it is just the time it takes the GPU to render things. I can't really tell from the videos. I'm also not very firm with the sample names for the SRP. As this is worse when looking at the ground, this seems to me like a fillrate issue so you might want to optimize that ground shader. But that's guesswork on my part.

    As to why doing stuff in the editor "fixes" things, it doesn't. It triggers repaints of the editor Windows which results in longer "EditorLoop" samples which in turn gives the GPU/RenderThread more time to finish the current frame before the next frame starts. I think the Stats window in the game view is trying to account for that by substracting time spend on doing Editor work from it's calculations.

    So as AcidArrow said, don't Profile in the Editor. The results from that are skewered. Also, Timeline view really is your friend here because it shows how the timings of the different threads affect each other.

    P.s. if your profile data does not contain any sensitive information (e.g. captured method names (Sample names) that might hint at things under NDA) you can save the profiler data to file, zip it and upload it to the forums (mentioning which unity version it can be opened with). That way it's easier to pinpoint issues than by going through a video frame by frame. ;)