Search Unity

Question Can't disable vSync (very odd case)

Discussion in 'General Graphics' started by subGlitch, Jul 27, 2020.

  1. subGlitch

    subGlitch

    Joined:
    Jan 27, 2015
    Posts:
    23
    QualitySettings / VSync Count is set to Don't Sync. Also I do following during Start():

    Code (CSharp):
    1. Application.targetFrameRate = -1;
    2. QualitySettings.vSyncCount = 0;
    But the game still runs on 60 FPS. The problem persists on both Unity 2019.3.7f1 and 2019.2.11f1. I don't have any overrides in my NVidia settings. Other games can run without vSync normally.

    Please, find example project in the attachment.
     

    Attached Files:

  2. Deleted User

    Deleted User

    Guest

    You don't use Debug.Log in your script; maybe you should to see what it has to say. :)
     
  3. subGlitch

    subGlitch

    Joined:
    Jan 27, 2015
    Posts:
    23
    Now I added Debug.Log():

    Code (CSharp):
    1.     void Start()
    2.     {
    3.         Debug.Log( $"Before: { Application.targetFrameRate }, { QualitySettings.vSyncCount }" );
    4.  
    5.         Application.targetFrameRate       = -1;
    6.         QualitySettings.vSyncCount        = 0;
    7.  
    8.         Debug.Log( $"After: { Application.targetFrameRate }, { QualitySettings.vSyncCount }" );
    9.     }
    10.  
    And I see in the log:

    Before: -1, 0
    After: -1, 0

    But the project still runs 60 FPS.

    By the way, in Unity Editor it runs with 245 FPS.

    What's happening here? Very strange...
     
  4. Deleted User

    Deleted User

    Guest

    It seems to be computer related; are you sure vSync is disabled in your GPU settings? And, if it is, are you sure there is no safety somewhere that would force vSync on even if you don't want?
     
  5. subGlitch

    subGlitch

    Joined:
    Jan 27, 2015
    Posts:
    23
    Yes, I'm sure. You can see it on the screenshot - it's NVidia Control Panel. It says "Use 3D application's setting". Same results if I change it to "Disabled". And same results if press "Restore" button, to restore global settings.

    But what it possibly could be? Especially if other games can run with or without vSync. Including my own old game, which I made on SDL2 & OpenGL. I suspect it's on Unity side.
     

    Attached Files:

  6. subGlitch

    subGlitch

    Joined:
    Jan 27, 2015
    Posts:
    23
    Actually, you are right! I've just tried same build on another computer and it runs without vSync normally.

    But what possibly can ban vSync disabling on my computer??? And how it can ban only Unity builds but not other apps? I can't understand...
     
    sirleto likes this.
  7. Deleted User

    Deleted User

    Guest

    I wish I knew too; I've noticed this behaviour on my current computer. My GPU is an Nvidia too.
     
    sirleto likes this.
  8. subGlitch

    subGlitch

    Joined:
    Jan 27, 2015
    Posts:
    23
    New results. Disabled vSync is working for Fullscreen Mode = Exclusive Fullscreen only. But for all other modes is not. And!!! This is only in Unity 2019.3.7f1 !!!

    In Unity 2019.2.11f1 disabled vSync is not working for all Fullscreen Modes !!!

    Extremely strange...
     
    Last edited: Jul 27, 2020
    sirleto and DropDrage like this.
  9. subGlitch

    subGlitch

    Joined:
    Jan 27, 2015
    Posts:
    23
    I'm happy that I'm not alone :p
     
  10. wesleythomas360

    wesleythomas360

    Joined:
    Feb 13, 2014
    Posts:
    2
    Having the same problem on a mac with AMD Radeon Pro 5500M . Any updates on this
     
    Last edited: May 22, 2021
  11. unity_Z32-r-X-tj3btQ

    unity_Z32-r-X-tj3btQ

    Joined:
    Oct 5, 2018
    Posts:
    2
    My mistake was very simple, as it turned out I forgot to uncheck Vsync (Game view only), this is where you can change the resolution and aspect ratio of the screen :)
     
  12. axtonjcranston

    axtonjcranston

    Joined:
    Jul 24, 2023
    Posts:
    2
    Is there a commandline switch for Unity games that will force vsync on when the game does not have it buit in?
     
  13. c0d3_m0nk3y

    c0d3_m0nk3y

    Joined:
    Oct 21, 2021
    Posts:
    666
    You can do it via the NVidia Control Panel
    upload_2023-7-24_18-55-53.png

    There might also be a way to enable it via boot.config if the game doesn't override it but couldn't find the variable name in a quick check.