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. Dismiss Notice

Change in FPS with 2020.2??

Discussion in 'Editor & General Support' started by btschumy, Dec 22, 2020.

  1. btschumy

    btschumy

    Joined:
    Jul 31, 2019
    Posts:
    91
    Something in the last couple of days has changed in my project that is resulting in lower FPS. One possibility was the upgrade to Unity 2020.2.

    I'm developing on a Mac and in the when running from the editor, I was getting anywhere from 500 to 2000 FPS. Now I'm getting between 60 and 120. Even if I turn off all my objects(uncheck in the Inspector), I still get this low range.

    I'm fairly new to Unity and it's possible I've inadvertantly flipped some setting somewhere that is causing this. Or maybe it is something about the 2020.2 upgrade.

    I've also tried adding:

    Application.targetFrameRate = 1000;​

    to Start() for the Camera but it doesn't help.

    Any ideas?
     
    JustMars and OmarVector like this.
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,756
    Joe-Censored likes this.
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Take a look at the Profiler. In newer versions of Unity the Profiler now gives VSync its own separate CPU Usage category, so it is pretty easy to spot VSync as the culprit. Previously you'd infer it by looking deeper into the data. Whenever you see FPS locked to a value roughly the same as a monitor refresh rate, VSync is probably a safe assumption, or at least a good first thing to check.

    Here's some good reading on using the Profiler for looking into these kinds of issues:
    https://learn.unity.com/tutorial/diagnosing-performance-problems
     
    Kurt-Dekker likes this.
  4. btschumy

    btschumy

    Joined:
    Jul 31, 2019
    Posts:
    91
    Tried setting the VSync setting to 0 in code as well as in the Quality project settings (VSync Count = Don't Sync). This didn't make any difference.

    It is curious that the FPS seems to hover around 60 (or occasionally in the 120 range).

    I'm aware that bumping the FPS higher than 120 probably will no have any useful effect, but I'm not done adding elements to the simulation and I want to make sure I haven't inadvertently set something incorrectly.

    I haven't tried profiling yet, but do notice that in the Stats window of the editor it shows:

    CPU: main16.7 ms; render thread 0.4 ms
     
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    But did you confirm in the Profiler it actually is VSync causing the performance drop? If it isn't, then the Profiler will show what else the CPU is spending all its time on.
     
  6. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,160
    The stats view is not an accurate or detailed profiling tool, especially before 2020.2 (and just in general because you are looking at Editor Playmode data). Pre 2020.2 it reported timings differently so that might explain why it looks like performance regressed while nothing in terms of performance actually changed. If you want to compare performance of the 2 versions, use the profiler, ideally in Standalone mode, and use the Profile Analyzer (a package) to compare the profile captures.

    Also, check if your resolution drop-down in the game view has vSync checked on, that would override anything else.
     
    S_Thibault and Lars-Steenhoff like this.
  7. btschumy

    btschumy

    Joined:
    Jul 31, 2019
    Posts:
    91
    I tried profiling, but this is the first time I've used it and it's not clear I'm interpreting it correctly. It seems that all the time is spent in rendering. However, I've built a version that has all my GameObjects disabled (unchecked) so the screen is blank and it still shows all the time in rendering.

    UnityProfile.jpg

    In this run I have the following in my Camera' Start() method.

    QualitySettings.vSyncCount = 0;
    Application.targetFrameRate = 1000;

    What else should I check?
     
  8. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,160
    On non-mobile platforms, targetFrameRate = -1 should give you the highest possible frame rate. Not too sure what 1000 would do of that can't be achieved. Be sure to check out the Scripting docs page on Application.targtFrameRate because its usage isn't quite that straightforward. I'm unaware of any hard limitation to the monitor refresh rate or in this case 60 FPS on OSX/Metal (mobile has those) but it looks like hat might be happening here?

    That graph is also way to broad in its categorization to allow a flat categorization. The details Panel below the charts is there to disambiguate these numbers.

    Check out this Unite Now 2020 video: Introduction to Profiling. We're also doing our best to make the Profiler documentation as informative and helpful in getting started and understanding how to use and read the Profiler.
    This:
    And for builds, I've seen users on Windows run into issues with tuning, overclocking or graphics driver software enforcing VSync on their editor and games. Not sure if something similar could happen on Mac as I'm not that much of a Mac user. After excluding everything else, this might be something to bring up in the Mac specific sub-forums.
     
  9. OmarVector

    OmarVector

    Joined:
    Apr 18, 2018
    Posts:
    114
    I've the same exact problem, suddenly its locked to 30FPS while targeting android platform.

    I've disabled Vsyc, run an empty scene with URP , 30FPS locked, setting targetFrameRate in code didnt change anything.

    Higher framerate actually reflect for me how to expect performance in mobile

    Example at old way:
    Editor: game run on 1000FPS, then I may expect it run 50-60FPS on my phone
    Editor: run on 30FPS , I cant even imagine it would run on mobile

    Now when editor run by default at 30 or 60FPS whiling setting target platform to mobile, now I feel like I must make a build to see how that effect the overall performance.

    I hope you you adjust that and make it like before.

    EDIT:

    Also I notice an awkward issue, when game view while the scene view is active, it run on 30FPS, if I switched the scene view with profilier view, suddenly the game view jump to 60FPS
     
    DavidZobrist and HalfGamesLab like this.
  10. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,160
    How did you disable VSync? Via Quality Settings or via Game View -> Aspect & Resolution -> VSync?
     
  11. btschumy

    btschumy

    Joined:
    Jul 31, 2019
    Posts:
    91
    I added the following to the Start() method of my main script.

    QualitySettings.vSyncCount = 0;
     
  12. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,160
    You should double-check the aspect dialog in the game view then, because that will overrule that setting in the Editor
     
  13. btschumy

    btschumy

    Joined:
    Jul 31, 2019
    Posts:
    91
    I assume you meant this? As you can see, it is off.

    VSyncOff.jpg
     
  14. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,160
    interesting. I'm not aware of any default frame rate locking and can't reproduce it on my machine so far.
    What Graphics API are you targeting? (Player Settings)
    Do you have any gaming overlays, graphics driver, overclocking or similar enforcing vSync? Maybe GSync? do you have multiple monitors attached and does detaching them change anything? (e.g. I get capped to 60fps when connecting my TV)
     
  15. OmarVector

    OmarVector

    Joined:
    Apr 18, 2018
    Posts:
    114

    I've GSync, but before it was ok until I made the upgrade to 2020.2
     
  16. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,160
    Does the frame rate get unlocked if you disable it?
     
  17. OmarVector

    OmarVector

    Joined:
    Apr 18, 2018
    Posts:
    114
    No, I did disable GSyc, and the problem still exist:)
     
  18. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,160
    @OmarVector do you have a multi monitor setup? what refresh rate do our monitors run at? And what happens if you disconnect some or all but one monitor?
     
  19. btschumy

    btschumy

    Joined:
    Jul 31, 2019
    Posts:
    91
    I do have a two monitor setup. Disconnecting the second monitor does make a significant difference.

    Running from the Editor with "Maximize on Play":
    2 monitors : ~60 FPS
    1 monitor : ~ 102 FPS

    Running a stand alone build on Mac:
    2 monitors : ~110 FPS
    1 monitor : ~ 150 FPS

    I'm happy with the performance with 1 monitor. If a customer has two, will they see the same performance drop?

    It is still a mystery as to why a build for iOS gets 30 FPS almost exactly. It really seems that something is clamping the frame rate there. As I've previously explained, I believe I have everything set to allow it to run as fast as possible.
     
  20. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,160
    I'm not entirely sure but I'd suspect your two monitors to have different refresh rates which is probably hampering your graphics card's / driver's or our graphics API implementation to output images at the highest possible rate?
     
  21. btschumy

    btschumy

    Joined:
    Jul 31, 2019
    Posts:
    91
    Both monitors are set to 60 Hz refresh rate. This problem just showed up with the latest Unity release so I suspect it was something changed there.
     
  22. valarus

    valarus

    Joined:
    Apr 7, 2019
    Posts:
    430
    Do you happen to have Windows 10 1909? I remember reading about nonconstant Time.deltaTime issues with multimonitors.
     
    Last edited: Jan 17, 2021
  23. btschumy

    btschumy

    Joined:
    Jul 31, 2019
    Posts:
    91
    No, this is on an iMac with an external monitor.
     
  24. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,160
    Try filing a bug report then. Not sure this isn't by design somehow but with a bug report we'd get that cleared up.
     
  25. vra_unity

    vra_unity

    Joined:
    Mar 12, 2018
    Posts:
    2
    I have the same problem. After update project 2019.4 to 2020.2 I'm getting <=60 fps. In 2019.4 I was getting between 200-300 fps
     
    JustMars and glacuesta like this.
  26. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,160
    If everything discussed in this thread also applies to your setup, it would be good if you could also report a bug on that. I don't know if @btschumy filed one before but even if, and if this is hardware dependent, then additional context on this happening on a different setup can help us narrowing down the issue.
     
  27. glacuesta

    glacuesta

    Joined:
    Nov 30, 2017
    Posts:
    10
    Just wanted to chime in here that I am facing the same. Normally I use the game view fps as a barometer to see how loaded the graphics are so I can get a quick idea of before-vs-after when I'm making changes. But I'm on 2020.3 and I'm seeing the fps locked to 60fps no matter what I do, so I am suspecting a hardware level cap. I too am on an iMac with 2 external monitors, though the same set up with 2019 versions of Unity did not have this behavior. I'll look into filing a bug report; haven't done one before.
     
  28. Filo_bt

    Filo_bt

    Joined:
    Nov 3, 2020
    Posts:
    1
    I had a similar issue, my project suddenly had performance drop. I just exported all the project as a package into a new project and the framerate bug was fixed
     
    Extrys likes this.
  29. Extrys

    Extrys

    Joined:
    Oct 25, 2017
    Posts:
    329
    Im having exactly the same issue, but it happens on Build too
    The game built on Android in unity 2020.1.0f1 runs at 72fps fixed in Oculus quest
    but after updating to 2020.2 or 2021.1.0f1 . the build runs at 40-50 fps now

    I don't know what to do, the workflow in the newer versions is better and the compilation time also
     
  30. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,160
    So far no one posted an issue ID into this thread so you I'd say, create a bug report on this?
     
  31. Extrys

    Extrys

    Joined:
    Oct 25, 2017
    Posts:
    329
    I will later today
     
    MartinTilo likes this.
  32. mellofelipe

    mellofelipe

    Joined:
    Jan 15, 2021
    Posts:
    2
    Facing the same issue with two monitors. Macbook pro 2019.

    Single Monitor - 60 FPS
    Dual Monitor (even with mirror and not extend) - < 30

    Just filled a bug report. I'll link it as soon as get an email with the tracking id.

    Running 2019 lts btw.
     
  33. mellofelipe

    mellofelipe

    Joined:
    Jan 15, 2021
    Posts:
    2
    Case 1327408_9n3plh7v8m337070
     
  34. FuzzyNori

    FuzzyNori

    Joined:
    Dec 6, 2012
    Posts:
    47
    I am having a similar issue without the second monitor being plugged in. I'm running unity 2020.3.0f1.

    I've done a test run where I have only a few 3D objects laying around and if i turn them all off the FPS jumps up again to "normal" values. I then started drilling down to find a culprit and I found that if I have even one object with a standard shader being loaded at any time, my FPS stays at a max of 30 and dips down to between 18~27 at the slightest camera movement.

    Remove the material from the object, everything is back to normal...

    This was not happening with older versions of unity, I used to be well in the 50~60 fps minimum.

    Edit:

    I just built the game and the FPS is fine. Its a Game View issue only in my case so far.
     
    Last edited: Apr 14, 2021
  35. FuzzyNori

    FuzzyNori

    Joined:
    Dec 6, 2012
    Posts:
    47
    Update:

    After upgrading to 2020.3.3f1 the problem seems to have been fixed, in my case.
     
  36. FuzzyNori

    FuzzyNori

    Joined:
    Dec 6, 2012
    Posts:
    47
    New update:

    I'm really sorry for coming in here and mixing issues up! Turns out in my case it was nothing to do with unity or its version.

    I was running unity in my laptop which was low on battery, I completly forgot it!
     
    sadstorygr likes this.
  37. OmarVector

    OmarVector

    Joined:
    Apr 18, 2018
    Posts:
    114
    Sorry Martine, that was rude from me forgetting writing back to you, yes, I've dual monitor setup, and when using only one, it has the same issue:))
     
  38. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,160
    @OmarVector Right so, one monitor or multiple doesn matter, but scene view open additionally to the game view does? That still means your editor is somehow capped to vSync, just with the sceneview it needs two vBlanls per repaint. And with the changes from 2020.2 of how the fps display is based on the whole repaint time of the editor instead of just the time needed for the game view main thread update (possibly ignoring longer GPU calculations when GPU bound), that at the very least became extra obvious with that update, even if the editor repaint time was previously already somehow capped to 60 FPS.

    If you still have your 2019.4 version, you could double check that with the profiler and see if your main thread when profiling the editor runs at 16ms, including EditorLoop times. If not, I'd say this is possibly a bug?
     
    OmarVector likes this.
  39. OmarVector

    OmarVector

    Joined:
    Apr 18, 2018
    Posts:
    114
    You are right, lucky that the current project I'm working on is using 2019.4.20f1


    upload_2021-6-24_17-58-38.png
     
    MartinTilo likes this.
  40. tgaldi

    tgaldi

    Joined:
    Oct 28, 2015
    Posts:
    102
    To add to this, I'm having the same issue (FPS seems to be capped at 30 in editor game view), but if I have it maximized (or maximize while running) it increases to 60. I'm using Graphy to check framerate.

    2020.3.13f1
     
    Last edited: Aug 4, 2021
  41. oleg_v

    oleg_v

    Joined:
    Nov 10, 2017
    Posts:
    68
    2020.3.11f1.
    The same issue: changed build target to android and got 60 FPS in Editor/PlayMode and 30 FPS on device.
    But... vSync disabled, empty scene, stable 60 FPS?
    Application.targetFrameRate was set to 75, 120 etc, no effect.

    Changed active Graphics API for PC (not android) from GLES3 to DirectX11 and got 200+ FPS in Editor/Play mode.
    But stable 30 FPS on Android for empty scene (for both Vulkan and GLES3 APIs).
     
    DavidZobrist likes this.
  42. sadstorygr

    sadstorygr

    Joined:
    Jul 22, 2014
    Posts:
    8
    "This", I wasted almost 2 hours of my life because of this. Plugged my charger back into laptop, 200-300fps again. Unity should make a "to check list" with this potential "issues". Thanks for the tip
     
  43. FuzzyNori

    FuzzyNori

    Joined:
    Dec 6, 2012
    Posts:
    47
    I was lost to the issue for 3 days, don't beat yourself up.

    It just happened to me again and I was lost again! I totally forgot it about it once more... but at least I remembered I had a post about this somewhere in the forums... ehe
     
  44. wesmag

    wesmag

    Joined:
    Mar 25, 2020
    Posts:
    34
    Having a similar issue. If the Scene view is open and/or the Inspector is visible on some asset (this case, a material) it the game view is locked to 30fps. Oddly, I have a tab open in the same window as the inspector, this has a custom editor tool in it, switching the tab to that unlocks the game view frame rate again.

    This is on a Macbook Pro, Big Sur 11.6, 16inch 2019 model
    Unity: 2020.3.12f1
     
  45. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    678
    Hi @MartinTilo

    It looks like I've hit a similar issue.

    Currently a game of mine launched with Application.targetFrameRate set to -1 (on Windows, Android & iOS). Windows & Android devices all ran at 60fps whilst iOS ran at 30fps (on a 2020 iPad)

    So I decided to add a target frame rate feature to the game to expand players options with regards to performance. Currently the options are Auto, 30fps & 60fps.

    This was implemented using the following code...

    Code (CSharp):
    1.     if (targetFramerate == 0)
    2.     {
    3.       QualitySettings.vSyncCount = 1;
    4.       Application.targetFrameRate = -1;
    5.     }
    6.     else
    7.     if (targetFramerate > 0)
    8.     {
    9.       QualitySettings.vSyncCount = 0;
    10.       Application.targetFrameRate = targetFramerate;
    11.     }
    The development\test machine specs are...

    SurfacePro3 with SurfaceDock (Dual 60Hz Monitors)
    Windows 10 (21H1)

    And Unity is...

    Unity 2020.3.20f1 (Medium Quality, Time.fixedDeltaTime = 0.0166666f / 60Hz)

    Now whilst initially testing on Windows, I observed the following...

    NOTE: TFR = Application.targetFrameRate & VSC = QualitySettings.vSyncCount

    Dual Monitors - Unity Editor

    Windows Refresh Rate = 60Hz
    Unity Screen.currentResolution.refreshRate = 60Hz

    TFR:-1 / VSC:1 = 100fps+
    TFR:30 / VSC:0 = 30fps
    TFR:60 / VSC:0 = 60fps

    Dual Monitors - IL2CPP Master UWP Build

    Windows Refresh Rate = 60Hz
    Unity Screen.currentResolution.refreshRate = 0Hz

    TFR:-1 / VSC:1 = 60fps
    TFR:30 / VSC:0 = 25fps
    TFR:60 / VSC:0 = 50fps

    Single Monitor - IL2CPP Master UWP Build

    Windows Refresh Rate = 60Hz
    Unity Screen.currentResolution.refreshRate = 0Hz

    TFR:-1 / VSC:1 = 60fps
    TFR:30 / VSC:0 = 25fps
    TFR:60 / VSC:0 = 50fps

    Internal Display - IL2CPP Master UWP Build

    Windows Refresh Rate = 60Hz
    Unity Screen.currentResolution.refreshRate = 0Hz

    TFR:-1 / VSC:1 = 60fps
    TFR:30 / VSC:0 = 25fps
    TFR:60 / VSC:0 = 50fps

    So when specifying 30fps it's actually running at 25fps. And when specifying 60fps it's actually running at 50fps (verified with two different frame rate counters). Far from ideal.

    Dual & single monitor setups seem make no difference, as does running on the internal display (disconnected from the dock)

    What is interesting is that running in UWP Screen.currentResolution.refreshRate is always reporting 0Hz. Could this be the source (or part of) the problem?

    I've yet to test Android & iOS.
     
    Last edited: Oct 14, 2021
  46. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,504
    Can you report a bug on this? It looks like Application.targetFrameRate doesn't work well on UWP. I don't exactly know why that is, but I suspect that the sleep function we use oversleeps and it hurts frame rate more than we intended.

    That said, I would advice not using Application.targetFrameRate and I'd instead suggest increasing QualitySettings.vSyncCount. That way, frame rate limiting options won't be useless to anyone who isn't on a 60 Hz monitor/display. For instance, on 144 Hz you could support 144 FPS, 72 FPS and 48 FPS with vSyncCount of 1, 2 and 3. On the other hand, if you tried to force 60 FPS on such monitor, your game will look stuttery.

    This should be harmless, that getter is just not implemented on UWP. It should not interfere with actual presentation, though. If you report a bug on this too, we can address it.
     
  47. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    678
    Hi @Tautvydas-Zilys,

    Thanks for the reply.

    Both bugs reported (1373342 & 1373355)

    With regards to your suggestion, I understand the logic behind that, even though I'm far from an expert on the subject.

    But looking at the following articles...

    https://support.unity.com/hc/en-us/...Target-frame-rate-or-V-Blank-not-set-properly
    https://docs.unity3d.com/ScriptReference/QualitySettings-vSyncCount.html
    https://docs.unity3d.com/ScriptReference/Application-targetFrameRate.html

    They seem out of date, especially the following comments...

    "Typically on mobile platforms the default frame rate is 30 frames per second"
    "iOS ignores the QualitySettings.vSyncCount setting"

    My game primarily targets mobile players, so I want to allow them to choose a frame rate without getting too technical.

    So I've settled on terms Auto, Reduced, Optimal & Maximum and am thinking the following would represent these...

    Auto

    Code (CSharp):
    1. QualitySettings.vSyncCount = 0;
    2. Application.targetFrameRate = -1;
    Reduced

    Code (CSharp):
    1. QualitySettings.vSyncCount = 2;
    2. Application.targetFrameRate = -1
    Optimal

    Code (CSharp):
    1. QualitySettings.vSyncCount = 1;
    2. Application.targetFrameRate = -1
    Maximum

    Code (CSharp):
    1. QualitySettings.vSyncCount = 0;
    2. Application.targetFrameRate = 999f;
    NOTE: I understand on some platforms Maximum may be the same as optimal.

    Does that look correct to you?
    Do the two calls have to be set in a particular order?

    Any advice would be much appreciated.
     
    Last edited: Oct 15, 2021
  48. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,504
    Your target platform matters a lot. Since you posted results from Windows & UWP, I assumed you were targeting desktop platforms. My advice doesn't directly translate to Android and iOS. I don't think that documentation is outdated: mobile platforms do target 30 fps by default to save battery life.
     
    PeachyPixels likes this.
  49. PeachyPixels

    PeachyPixels

    Joined:
    Feb 17, 2018
    Posts:
    678
    Ok, thanks.

    I've dropped Auto (in the above example) as it didn't seem right to me.

    So after changing Auto/30/60 to Reduced/Optimal/Maximum on Windows UWP (switching from TFR to VSC) it produces FAR better results.

    With a 60Hz display, it produces a rock solid 30fps at Reduced, a rock solid 60fps at Optimal and 200+ on Maximum. As expected, but still nice to see. Especially as using TFR (-1/30/60) resulted in fluctuating frame rates.

    Will test on iOS & Android on Monday and see what they produce.

    Thanks for the tip! :)
     
  50. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,504
    The fix for Screen.currentResolution.refreshRate returning 0 on UWP landed to 2021.2.6f1 and 2020.3.25f1. The fix for target framerate not working as it should on UWP is in progress.