Search code examples
iosunity-game-engineoptimizationframe-rate

Unity performance spikes at 30 FPS


I am developing a simple game for iOS using Unity engine. I am using Application.targetFrameRate to set the target fps for my game. When I set target fps to 60 or 45, the game runs perfectly on any iOS device, but if I set targetFrameRate to 30, the game runs with spikes and jitter. I don't know why this is happening (30 fps must be OK).

I attached the Profiler to my iPhone and saw that when running at 30 fps, some frames are rendering at 200 fps, others at 45-60 fps and this causing the awful performance spikes. But this is not happening when targetFrameRate is 45 or 60.

I really need my game to run at 30 fps to avoid heating and throttling. Someone please help me!


Solution

  • I'm guessing at the underlying issue here but setting targetFrameRate throttles the frame through logic on the CPU while setting QualitySettings.vSyncCount lets the GPU handle the throttling. My guess is, that setting QualitySettings.vSyncCount = 2 should provide a smoother experience. You can also set this manually in your QualitySettings instead of by code.