Search Unity

Question Changin VSync Count doesn't affect FPS on editor playmode

Discussion in 'Editor & General Support' started by tamana, Aug 29, 2022.

  1. tamana

    tamana

    Joined:
    Mar 14, 2017
    Posts:
    17
    Hey after upgrading from 2018 to 2020, we noticed that VSync Count on ProjectSetting -> Quality settings does not change the fps when entering playmode on editor.
    Previously on 2018 setting VSync Count to Every Second V Blank will lock fps to 30 on playmode. But, on 2020 the fps reach above 200 and changing VSync Count to other options wont change the output fps.

    Ah, yes I know in 2020 you can enable VSync with Game window by clicking Vsync (Game view only) on change resolution dropdown menu. But that doesn't solve our problem.

    Is there a way to lock the fps down to 30 with VSync Count ?
    I know I can set the fps to 30 with Application.targetFramerate. I just want to know why VSync Count doesn't work anymore after the upgrade and is there someway to make it work again like 2018 ?
     
  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    Hello,
    The Editor never used vSync to begin with, it only emulates it via Application.targetFramerate. The changes to put a VSync option on the Game View and to put the previously implicit Editor throttling of 4ms into the Preferences under
    Preferences > General > Interaction Mode
    probably just made the previous behavior more explicit. It might've also clashed with the previous default behavior, I can't entirely recall the reasoning. But you should be able to get the refresh rate of the Editor locked down to 30 FPS again using these two options.

    (Also pre 2020, the Stats view was technically lying about the effective FPS by calculating out the Editorloop time)
     
  3. tamana

    tamana

    Joined:
    Mar 14, 2017
    Posts:
    17
    Martin Tilo.
    No, I still can't get 30 FPS even after changing Interaction Mode to say,, Custom Mode and set the frame throttling to 33ms. Is locking FPS on editor to 30 becoming impossible after the upgrade?
     
  4. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    That sounds more like a bug then. Could you please report that via Help > Report a Bug?
     
  5. tamana

    tamana

    Joined:
    Mar 14, 2017
    Posts:
    17
  6. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    If I understand this correctly, your monitor refresh rate is 360Hz, so
    Every Second V Blank
    would throttle to 230 FPS, not 30 FPS. Does that match what you are seeing? If so, I'd correct my previous assessment and say the old behavior was technically incorrect.

    Meanwhile, the
    Interaction Mode
    setting should take effect on the Editor redraws outside of Playmode only.

    So I guess with such a high refresh rate, Application.targetFramerate might be the only current workaround to get the logically correct working Editor to not run way too fast on such a monitor... (You could use Screen.currentResolution.refreshRate to detect such monitors and only use this workaround then).
     
  7. tamana

    tamana

    Joined:
    Mar 14, 2017
    Posts:
    17
    Can you please tell me the math behind on how you get 230 FPS from 360Hz with Every Second V Blank?
    And, no. If I run on empty scene, the fps will go to 144fps ( with 144Hz monitor ).
    Yes, Every Second V Blank is technically not working currently.
    I'm now waiting for the responses from the Unity's team.

    Yes, I know by using Application.targetFramerate I can limited the fps to 30.
    But our team was previously using Every Second V Blank from version 2018,
    and the frame limiter is not working anymore after we upgraded the project to version 2020.
     
  8. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    Nah, because my math brain messed up on me. I meant 180FPS. But if a 144Hz monitor doesn't go down to 72FPS with QualitySettings.vSyncCount=2 then, yeah, the frame limiter in the Editor (which isn't using vSync in the editor but in my understanding should at least Mimik it) is bugged. 30 would still be wrong though.

    In other words it never worked correctly to begin with...
     
  9. EdwardFalzon

    EdwardFalzon

    Joined:
    Mar 16, 2014
    Posts:
    7
    Hi @MartinTilo, I believe this problem has been plaguing Linux-based devs for several years. Is there any solution coming?

    I have done some homework. Below is a big screen-shot of the Game windows in play mode for the latest/final revision of every version of Unity from 2017 to 6000. I installed all of these versions today, 30 March 2024, through Unity Hub v3.7.0, on my Ubuntu MATE 22.04 PC.

    My process was simply to create a new, empty 3D project with built-in pipeline for each version, maximise the Game view, open the stats panel and press play on the empty default scene. (I resized the windows for smaller screen-shot dimensions). I can't attach more than five files to this post, so individual screen-shots can be found here: https://mega.nz/folder/RMUExb5J#V6f4JmE8OptuQdGI5OVNrg

    To establish that this is not a hardware-performance problem, I also ran all eight projects simultaneously, as shown in the screen-shot below.


    Unity All Versions FPS Screenshot at 2024-03-30 17-55-33.png


    Having searched around for a solution, I have tried/confirmed the following recommendations; they seem to have no effect in any version from 2020 up (I did not feel the need to try these on older versions that are running at ~1,500 FPS):
    • Toggle Game-view vSync on/off;
    • In Project settings, remove all settings except Very Low, set VSync to any value;
    • In Preferences, change Interaction Mode to any value;
    • Close Scene view;
    • Set QualitySettings.vSyncCount to any value; and
    • Set Application.targetFrameRate to -1 and any value above 30.
    I'll note three things:
    1. My monitor runs at 30Hz;
    2. Setting Application.targeFrameRate to a number between 2 and 29 does cause the Game view to slow down to hit that target; and
    3. All projects that run at 30 FPS in Linux run at 500+ FPS in a Windows VM.

    I went a little further and pinpointed the exact version and revision where my FPS changes from 2k-3k down to 30: It's v2020.2.0. The previous version, v2020.1.17, works great and was released five days earlier.

    Unity 2020.1.17 FPS Screenshot at 2024-03-30 19-04-51.png
    Unity 2020.2.0 FPS Screenshot at 2024-03-30 18-54-48.png


    I hope this is enough information to (a) show that this is a very lingering problem whose time has come; and (b) pinpoint the offending code and fix it in all versions currently under development.

    Thanks.
     
    Last edited: Apr 3, 2024
  10. Agoxandr

    Agoxandr

    Joined:
    Aug 16, 2014
    Posts:
    52
    Pretty dramatic post, but VSync works on my machine with KDE Plasma with a built project as expected. In editor it will work when you click this checkbox.
    upload_2024-3-30_17-23-11.png
     
    MartinTilo likes this.
  11. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    That's not how Unity version releases work. 2020.1 branched of from trunk (which then turned into 2020.2.0a1) with the start of the beta and then only got fixes backported. The change could have happened at any point between 2020.2.0a1 and 2020.2.0f1.

    Though please report a bug via the Editor Menu
    Help > Report A Bug
    so this can be looked at, also with a bit more context info on your system (GPU, driver and monitor)