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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Bug The EditMode and PlayMode of Unity sometimes run at 10fps

Discussion in 'Editor & General Support' started by JavierOlvera, Jun 12, 2022.

  1. JavierOlvera


    Sep 10, 2019
    Hi! Recently I've been having several problems with Unity. When I hit play, the game sometimes start running at 10fps and other times at +160fps (which is supposed to be the usual frame rate). The problem is not related to the optimization of my game because I've tried to run the game deleting every gameobject and it still happens (also as I said before, it sometimes run at +160fps).

    The problem consist of:

    -Unity is running as usual

    -I hit play

    -The game starts running at 10fps as maximum (sometimes this doesn't happen and everything looks normal)

    -I wait without doing anything (1-3min) and the frame rate starts running as usual (+160fps)

    *When I wait until the game runs as usual, if I left unity running in background (or I leave the windows tab oppened), it seems to take less time to run as usual again (less than 1min). Also, the problem happens more frequently when I'm have PlayMode maximized in fullscreen.

    -I stop the PlayMode and go back to Edit Mode, and (sometimes) once I'm in EditMode again, the editor runs at 10fps (aprox) too, and I have to wait until it starts running as it is supposed to be.

    *Also, when I modify something in the code, when Unity ends compiling, the editor runs at 10fps gain (to fix it I leave Unity running in background as I said before, so it fixes itself faster).

    Since I created the project, Unity seems to have this problem more frequently (the project has 13-14 months aprox). When I started the project this did not happen, but over the time, the problem is getting more intense and nowdays it's really tedious to keep working on the project (Unity also crashes a lot in random moments, usually when ends compiling or when I hit play. I gess it's probably related to the framerate issues). I haven't asked this before because I thought that the problem was from the Editor, but I've started to do some builds and this happens in the build too (sometimes you execute the .exe and it runs at +60fps and other times it runs at 10fps).

    Also, if I use Unity for a long time, it seems to happen more frequently. If I restart Unity, it takes over 15 minutes to start happening again and it gets more intense with the time. I don't remember any recent day in wich Unity was able to keep working for 2h without crashing.

    I dont know what to do but each day the problem seems to be worse and nowdays Unity crashes at least 4 times each day and almost every time I hit play the frame rate bug happens again.

    I don't know if this could be related, but I have a script to set the maximum frame rate to a customizable number:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    5. public class LimitFPS : MonoBehaviour
    6. {
    7.     public bool CanLimitFPS = true;
    8.     public int targetFrameRate = 60;
    9.     public bool ShowFPS;
    11.     void Update()
    12.     {
    13.         if (CanLimitFPS == true)
    14.         {
    15.             Application.targetFrameRate = targetFrameRate;
    16.         }
    17.         else
    18.         {
    19.             Application.targetFrameRate = -1;
    20.         }
    21.     }
    23.     void OnGUI()
    24.     {
    25.         if (ShowFPS == true)
    26.         {
    27.             GUI.Label(new Rect(0, 0, 200, 50), new GUIContent("FPS: " + 1 / Time.deltaTime));
    28.         }
    29.     }
    30. }
    The problem happens if CanLimitFPS is true, if CanLimitFPS is false or even if the code is not in any gameobject in the scene, so I don't think it's related to the problem.

    I posted a video to show the problem, you can see the framerate in the top-left of the screen. When it runs as usual, it has over 40fps because I was testing with a lot of enemies, but it usually runs at 160fps.

    During the short video, the editor did not run at 10fps at any time because it happens at random moments, but it usually happens too.

    I'm using Unity Personal 2020.3.10f1 and HDRP.

    My computer:
    -Windows 10
    -CPU: Pentim i5 11400
    -35GB RAM ddr4 3200mhz
    -GPU: GEFORCE RTX 3070


    I recorded another video showing the profiler when the problem is happening and when everything looks normal. The problem seems to be Gfx.waitForPresentOnGfxThread but I don't really understand what is it and why it causes this problem randomly when I start the game and then it dissapears. Now I think the problem is related to my graphic card settings.


    Finally, I watched the next video where someone had a similar problem and he ended up restoring his settings in Nvidia's control panel (3:41 minute). I'm scared that someone who plays my game has to modify his graphic card setting to play it correctly, so I would like to find any other solution.

    The last thing I want to say is that english is not my native language, so sorry if I had any grammar mistake. I hope you understood me correctly.

    I will aprecciate any tip or solution, I really need it. Thanks for reading.

    Attached Files:

  2. Kurt-Dekker


    Mar 16, 2013
    See pinned posts, top of this forum. Some of the items in the editor freezing notes may help you.
  3. JavierOlvera


    Sep 10, 2019
    I restored my Nvidia's settings and it seems to work.

    However, I still don't understand why does the Gfx.waitForPresentOnGfxThread causes the problems randomly and not always. I would also like to know if any other players playing the game might have the same problem.
  4. JavierOlvera


    Sep 10, 2019
    Thanks for the reply! Finally I discovered that the problem is directly related to theGfx.waitForPresentOnGfxThread and the graphics card settings. That is not mentioned in the posts you mentioned, but they might still help me with the problems I have with Unity crashing. Thanks!
    Kurt-Dekker likes this.
  5. CodeSmile


    Apr 10, 2014
    Resetting Nvidia settings probably helped because one can tweak the heck out of the driver with unknowable side effects. Usual culprits are forcing vsync/gsync in a specific mode (messes with timing in apps that don’t expect this) or number of frames to render ahead (=increasing input lag) and some quality options that can noticably increase GPU load or memory usage.

    And of course any of this in combination with an outdated or buggy driver version.
  6. JavierOlvera


    Sep 10, 2019
    Okay so I guess the problem was just in my computer and any other player should have it. Thank you so much!
  7. JavierOlvera


    Sep 10, 2019
    Well, since I restored Nvidia's settings the frame rate has increased and the problem was not happening anymore but a few moments ago it went 10 fps again and crashed. Now it seems to happen with less frequence than before, but I still don't know how to fix it. I'm going to reinstall all Nvidia's drivers and test it for a while to see if anything has changed.

    I really hope this is a problem of my computer and not of the game, otherwise I will not be able to release it because this will happen to many other players.

    I'll post any progress here! I would need some more help to fix this
  8. JavierOlvera


    Sep 10, 2019
    I’ve discovered that it’s related with the realtime shadows, when I diseable them (or set them as low res) the problem seems to stop happening. Anyways, I still don’t understand why the fps decrease just during the first seconds of the game.