Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Quality Settings V Sync Count Not Working

Discussion in 'Editor & General Support' started by GossamerGames, Aug 21, 2019.

  1. GossamerGames

    GossamerGames

    Joined:
    Jul 12, 2017
    Posts:
    30
    Hello, I am setting the v sync count to "Every V Blank" or "Every Second V Blank" And in my main script I am calling
    Application.targetFrameRate = 30;


    Is there something I am doing wrong here? Why would the framerate be ~40 most of the time and drop down to 60FPS?
     
  2. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    What platform?
     
  3. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,432
    Since you've tagged this thread with the "profiling" tag, am I right to assume you're getting the FPS from the Profiler Window? Maybe even by profiling the Editor? That could be down to this bug that I'm working on fixing, where the "Other" Catgory doesn't show up in the graph unless you select samples, e.g. PlayerLoop or EditorLoop. So for the moment, don't go by the Charts in the Profiler to measure your FPS.

    If you're using the Stats overlay in the game view, those "measurements" are trying to calculate the overhead of running the Editor running on the same main thread as the Playmode Player out so I wouldn't rely on that.
     
  4. GossamerGames

    GossamerGames

    Joined:
    Jul 12, 2017
    Posts:
    30
    I noticed the vsync was not showing in profiler in the editor, but also, it seemed to drop in PC builds and also on Xbox builds when I was syncing it to the profiler, I noticed what looked like FPS drop, but really it showed it was just fluctuating a lot between 30 and 60.
     
  5. GossamerGames

    GossamerGames

    Joined:
    Jul 12, 2017
    Posts:
    30
    I was using the profiler to get these stats, I can double check that the FPS is constant, however, when I was running my build and attached it to the profiler, I saw that it would be running smoothly at around 40 FPS, then jump up to 60 and jump back down to 30 and I could clearly see that reflected in the build I was running as well, It could have been the case that it was going lower but the profiler was not showing that clearly?
     
  6. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,432
    so I'm unsure about the 40FPS
    that sounds like there is no VSync and a targeted 60 FPS that can't be reached, or actual 30 FPS but the Chart doesn't show you the whole truth due to the mentioned bug.
    For the switching between 30 and 60 FPS, that sound like you've set VSync to every vBlank but miss it every couple of frames, oscillating back and forth. Depending on how you're calculating your FPS (e.g. average over frames) that could also lead to a stat of ~40FPS where it is averaged out.
    As per the docs, the VSync setting overrides Application.targetFramerate:

    "Additionally if the QualitySettings.vSyncCount property is set, the targetFrameRate will be ignored and instead the game will use the vSyncCount and the platform's default render rate to determine the target frame rate. For example, if the platform's default render rate is 60 frames per second and vSyncCount is set to 2, the game will target 30 frames per second."
     
  7. GossamerGames

    GossamerGames

    Joined:
    Jul 12, 2017
    Posts:
    30
    Thanks for this information, this could be where we are going wrong. We have vsync count set to every second, and we also have the Application.targetFramerate set to 30. I was under the impression they were to be used together, not realizing the vsync count was dependent on the machine.
     
    MartinTilo likes this.
  8. GossamerGames

    GossamerGames

    Joined:
    Jul 12, 2017
    Posts:
    30
    @MartinTilo Sorry for taking a while to get back to you on this issue. I have created a new build of my game, I have gone through every quality level and changed the "v sync count" to "Don't Sync" I have also ensured that this value is not changed in the code. Also, I have ensured that the Application.target framerate is set to 30, via "Application.targetFrameRate = 30;" As I run my game right now, I can see that the FPS is jumping around 70 - 76 fps.

    I am unsure why this is or what could cause it. I have also tried to set the vsync count to every other and every v blank and nothing seems to work for me.

    EDIT: I am unsure why, but I changed it back to every other, and now it says it is running at 30.
     
    Last edited: Sep 3, 2019
  9. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,432
    Hi @GossamerGames,
    No worries on the delay. What platform are you running this on (still PC and Xbox?), which unity version are you using and where do you get the FPS from, or how do you calculate the FPS?
     
  10. GossamerGames

    GossamerGames

    Joined:
    Jul 12, 2017
    Posts:
    30
    @MartinTilo it seems to be working now, however, I was testing this on Xbox, and the FPS comes from the console itself, so I wasn't doing any of the calculations.
     
  11. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,432
    Very Strange. But good it's working now. If it happens again, in a reproducible way on a recent (patch) release, please file a bug :)
     
    GossamerGames likes this.