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?
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.
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.
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!
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.
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?
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!
Bro, what even this? (Not asking, just reaction to how wild this is) Unity has to do something with this, like Godot for example. There is a vsync option, so if it is on, they always target the default frame rate of the current device when playing the game. And you can change the fps later via some API. The only way I can make this work is to set targetFrameRate = 90 (my default framerate of the phone I’m using) and then I can make a setting for changing the frame rate to 30-60-90-120. Funny how if I change my phone frame rate to 60 then even the targetFrameRate = 90 at the beginning. It will change it to 60. Funny how.
Okay, the Optimized Frame Pacing must be disabled
Because if that enable then when I run this at the start
Screen.currentResolution.refreshRateRatio.value;
It always returns 30.
But if I disabled Optimized Frame Pacing
and then at the start of the game. I just
Generally on Android, the default Framerate is 30 (to save battery). Frame Pacing is disabled by default and Adaptive Performance is not installed (so installing it and disabling it is not a valid solution for the initial problem - it still might work for other reasons but you should not have to do that to get to your targetframerate).
BTW, if you are using Adaptive Performance (and we had some bugs in 5.1 make sure to update to 5.1.1) we recommend to not enable Optimize Framepacing and use no vsync.
Generally if you use vsync it will change/sync to the display refresh rate (without anything else turned on). This (can) and will be changed by the OEM. Sometimes, you can try this by changing your bundle ID and see if your app is locked to a certain framerate by the OEM.
Framepacing will change it, and that’s on purpose to improve performance. Using a specified target framerate will not be the best way to control the system on a frame by frame base, you basically hand it over to the OS.