Search Unity

Question Game locked to 30FPS despite setting target frame rate to 60.

Discussion in 'Android' started by Domac_, Aug 23, 2021.

  1. Domac_

    Domac_

    Joined:
    Dec 29, 2019
    Posts:
    3
    I am working on a 2D platformer which used Universal Render Pipeline, however due to some instability issues regarding that pipeline, I switched back to Unity's default renderer and my game's FPS was solid 60 without a single drop when I first tested it on my device.

    After I made some minor adjustments to the scene (set textures' shader to Diffuse and added a light to the scene to make it "darker"), I built the game and ran it on Android, only to be greeted with a locked 30FPS, even though I set Application.targetFrameRate = 60; in my Start() method.

    This is what the profiler shows, first screenshot is without the vSync profiled module, second one is with:



    Now I ain't a professional when it comes to using the profiler, but I feel like my issue is caused by vSync somehow being turned on and the game being locked to 30FPS or something, which is weird, because I disabled vSync both in the Quality settings, and through the script (vSyncCount = 0;), and yet my game is still locked to 30FPS.

    I am fairly certain my device's refresh rate is not 30Hz, and to further make sure I even enabled refresh rate display in developer settings and it does display 60Hz.

    Did I maybe miss some setting, or something? Is my issue even caused by vSync?
     
  2. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    835
    Check your player settings if "Optimized Frame Pacing" is enabled. Disabling it might fix your problem.
     
    PrisedRabbit and MartinTilo like this.
  3. april_4_short

    april_4_short

    Joined:
    Jul 19, 2021
    Posts:
    489
    Do you have an absolute list of exactly what needs to be set to what, to get 60fps on Android?

    And 120fps on Android?

    Getting this right has always been a game of matrix testings of settings, and it's never quite certain why it's not the same between versions.
     
  4. Domac_

    Domac_

    Joined:
    Dec 29, 2019
    Posts:
    3
    I disabled it now, but no change, game is still locked to 30FPS.

    What I did notice though is, for the first frame or two, the FPS counter actually shows 60FPS, but then the game just locks to 30 and doesn't go above that.
     
  5. Berthil

    Berthil

    Joined:
    Aug 26, 2013
    Posts:
    22
    Hi

    Did you managed to make your game run with 60 FPS?

    Im Having the same issue. Even just a cube with no movement gets 30 FPS. Im using Unity 2021 with URP for Android.
     
    kwcnasa likes this.
  6. admoraguilar

    admoraguilar

    Joined:
    Sep 13, 2019
    Posts:
    9
    Hi

    I've just got into this same issue, but maybe mine is different reason.

    I'm working on my game and it's always 60 on the editor and became locked to 30 the next day I worked. After a lot of searching I tried something out. Basically I'm working on a gaming laptop and so I plugged in the charger, and now it's back to 60. So the conclusion for my problem is I'll be locked to 30 if on battery, and be unlocked if I go with plugged.

    Probably could go unlocked to on battery if I set my Windows battery settings to Better Performance, but it's alright I like my battery life more. Wish that there's just some info about this though, so it's not a waste of time searching for answers thinking you have something wrong in your game.
     
    xucian and TheIronHobo like this.
  7. leezak5555

    leezak5555

    Joined:
    Jan 16, 2020
    Posts:
    11
    Check your player settings if "Optimized Frame Pacing" is enabled. Disabling it might fix your problem.
    Thanks! That has actually helped me and solved my problem!
     
  8. unity_B4Ps5BamZ68Ouw

    unity_B4Ps5BamZ68Ouw

    Joined:
    May 10, 2020
    Posts:
    3
    Edit >> Project settings >> Adaptive Performance >>

    Uncheck Adaptive performance on startup
    Uncheck providers

    U r welcome :)
     
  9. abhimanyu-singh

    abhimanyu-singh

    Joined:
    May 24, 2016
    Posts:
    11
    Thanks. This worked for me.

    Even though I didn't have the Adaptive Performance Package installed in my project, it was still locking at 30 FPS. It asked me to install the package which I did and then followed your steps.

    And it worked. :)
     
  10. TheIronHobo

    TheIronHobo

    Joined:
    May 7, 2013
    Posts:
    4
    I was going insane but this worked for me. Thanks!
     
    Chocospleen likes this.
  11. Racsoth

    Racsoth

    Joined:
    Feb 20, 2015
    Posts:
    11
    The "Adaptive Performance Package" solution was the way to go for me. Thanks!

    There's a small caveat: every time I build, a warning popup appears saying that I haven't set a provider. Any idea if it's possible to disable that popup?
     
    xucian likes this.
  12. Racsoth

    Racsoth

    Joined:
    Feb 20, 2015
    Posts:
    11
    I ended up installing a provider and then disabling it. :shrug:
     
  13. Kadir-

    Kadir-

    Joined:
    Mar 24, 2020
    Posts:
    14
    void Update()
    {
    Application.targetFrameRate = 60;
    }
    only in this case woked for me when Application.targetFrameRate= 60 was in update method.
     
    patbb likes this.
  14. patbb

    patbb

    Joined:
    Apr 30, 2015
    Posts:
    1
    thanks. that's the only thing that worked for me too!

    You can try adding it in the Start() method instead of the Update() to only set it once when the game starts and avoid updating it every frames for the entire game

    it's a weird problem!


    Thanks everyone for contributing and finding solutions!
     
    Kadir- likes this.
  15. tw00275

    tw00275

    Joined:
    Oct 19, 2018
    Posts:
    92
    I found that the target framerate was being reset to 30 when the scene was changed, so subscribing to this event solved it for me:

    SceneManager.sceneLoaded += OnSceneLoaded;
    void OnSceneLoaded(Scene scene, LoadSceneMode mode)
    {
    Application.targetFrameRate = 60;
    }
     
  16. WildWildSchmax

    WildWildSchmax

    Joined:
    Jun 24, 2022
    Posts:
    1
    For my issue, I called Application.targetFrameRate = 60 in Awake() instead Start(). Put this to Start() and it should work