Unity framerate still synced to vsync instead of target framerate

Hi guys!

Been researching into this issue a bit and have seen tons of issues with Android in relation to this kinda thing but unfortunately I’m experiencing this during Windows builds.

Breakdown of my problem:
I have an issue where no matter what values I set QualitySettings.vSyncCount to, and what I set Application.targetFrameRate to, when building the game and running it the framerate always returns to whatever vsync would have it as.

Things I’ve tried:

  • Setting QualitySettings.vSyncCount to 0 (and making sure it stays at zero during runtime which it does)
  • Setting Application.targetFrameRate to a value that’s different from the vsync target framerate (and making sure it stays at that during runtime which it does)
  • Going into quality settings and setting VSync Count to “Don’t Sync”

Strangely enough, it only becomes an issue when the project is built, in the editor it works perfectly.

Quality settings:

Is there anything I’m missing that could be forcing my target framerate?

Can you show the code you use to configure it and then measure it? While it’s not recommended (due to the fact that it will cause horrible experience for people that have monitors with a refresh rate that does not align with your target framerate), doing this should work:

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

For debugging purposes I had this setup:

void Update()
{
    QualitySettings.vSyncCount = 0;
    Application.targetFrameRate = 240;

    Debug.Log(QualitySettings.vSyncCount);
    Debug.Log(Application.targetFrameRate);
}

(obviously updating this every frame isn’t ideal but I was making absolutely sure so I attached this simple script onto an object and let it go crazy - there were no other scripts running that were changing these variables)

What was the Screen.fullScreenMode set to? How were you measuring frame rate and what was it running at?

Is there any chance your graphics driver (for instance in Nvidia control panel) is configured to force vsync?

The issue was tested on 4 separate machines all encountering the same issue, the framerate was calculated via deltaTime and the game is on ExclusiveFullScreen

Also worth mentioning the framerate was different on the machines depending on their refresh rates

Can you show the code that calculates the frame rate? I cannot reproduce this in 2021.3.10f1:

I also attached my test scripts.

8526401–1137536–ResolutionConfigurator.cs (2.17 KB)
8526401–1137539–DisplayInfoTextScript.cs (1.49 KB)
8526401–1137542–FPSMeter.cs (856 Bytes)

The unity version I’m using is LTS 2020.3.38f1

To simplify the problem I’ve recreated the bug on an extremely simply scene:

It consists of a cube as the floor that has the “Begin” script attached and the canvas and TMP Text with your FPSMeter script attached (vSyncCount is set to Don’t Sync in settings) - I’ll attach the scripts just incase. I’ve done nothing else to the project so it’s entirely possible I’m missing something?

Seems to work fine in the editor (but not in the build)

8528834–1138253–Begin.cs (243 Bytes)
8526401–1137542–FPSMeter.cs (856 Bytes)

Can you also attach the DisplayInfoTextScript so it display info in your screenshot?

I’ve added the script but unfortunately it couldn’t find a definition for the RefreshRate class so I removed it:

What graphics card do you have?

NVIDIA RTX 2060

Can you show your nvidia control panel settings?

My settings:


1 Like

That’s what adaptive sync does: GeForce Graphics Cards - Ultimate PC Gaming

Turn it off and the issue will go away.

1 Like

Ohhh okay, would this limit fps for all unity games? - Just wondering why I haven’t noticed this until now lol

It’s working! - Thank you, your help was great :smile:

Just as a side thing, is there a good way to tell when graphics card settings are overriding application settings during runtime?

It would limit FPS for all games running on your computer, not only ones made in Unity.

Not really. Those driver settings are made so the application would have no chance of detecting or defeating them.

I see, thanks for all your help :slight_smile: