- Home /
Massive Overhead on iPhone 4
I have created a game entirely using Unity 4.6's new UI system. It seems to run perfectly on most devices (running at either 60fps on newer devices or 30fps on the iPhone 4s/Galaxy S2).
The problem I have (as I always seem to have) is with the iPhone 4. The framerate drops heavily to around 5fps. The only thing that Unity can tell me about this is that the "Overhead" is taking around 200ms to complete. I have had a look through the other answers here and found various ways to optimise for mobile devices and cannot find anything that has made a noticeable impact.
Does anyone have any clue what this could be referring to that is specifically for iPhone 4?
Thanks in advance!
Edit: To clarify it is not vSync or the Garbage Collector. I have also set the Quality Setting to Fastest and it made no difference. Unity profiler reports the Overhead as "Other".
I have no particular experience of iPhone 4, but "Overhead" commonly means waiting for vSync - i.e. nothing's going on, but your game is waiting for the display to be ready for the next frame before continuing. What vSync settings do you have?
vSync is turned off for my mobile builds. Though it's my understanding the iOS forces it on regardless of Unity's settings. That said the profiler states "Other" for the CPU usage, not vSync.
To clarify it is not vSync or the Garbage Collector. I have also set the Quality Setting to Fastest and it made no difference.
I wouldn't be surprised if you were GPU bound on the iPhone 4, since its GPU is pretty terrible for the resolution of the screen. It's the same GPU as the 3gs but four times as many pixels. I know you said vsync isn't showing up in the profiler, but perhaps it has been rolled into the 'overhead' tag. Is there no WaitForPresent or Device.Present? Are you drawing any large triangles (full screen or large parts of the screen)? Are you drawing many alpha blended or tested triangles, or using the discard instruction in a shader?
Yeah the GPU has caused issues before. I have no idea what Apple were thinking...
WaitForPresent and Device.Present are both absent. There are a few full width images being displayed (about 1/6th of the screen height) and a small alpha-blended button, nothing significant. Removing the button makes littler-to-no difference. Even removing all the images displayed only brings the framerate up to around 12fps (at that point it's just a black screen, all other game objects that contain anything renderable are disabled).
Answer by Orbonis · Jan 09, 2015 at 02:30 PM
The answer to this is Atlassing your textures (or alternatively using Unity's packing tag if you have Pro).
For Pro users this link is helpful: http://docs.unity3d.com/Manual/SpritePacker.html
Alternatively creating the sprite sheet yourself using an external tool, then importing it, works in much the same way.
The iPhone 4's GPU seems to struggle with swapping between multiple textures. Using the sprite packer reduces the draw calls and takes the strain off the GPU.
It should be noted that, while this greatly improved performance, Unity UI does not batch font textures. So each new font you use is an additional draw call for that layer. I'd recommend baking text where possible, though this may not be ideal for localisation.
Answer by tiz777 · Dec 05, 2015 at 04:36 PM
Had the same problem as @Orbonis
Solution that worked for me is to use Mobile/Particle/Alpha Blended shader for all the UI Image in the scene.
Only problem is with masks, in order to correctly work with them, I modified the Alpha Blended shader following this answer: http://answers.unity3d.com/questions/980924/ui-mask-with-shader.html
and used it for images that needs to be masked.
Hope could help someone!
Your answer
Follow this Question
Related Questions
[Unity 4.6] Button Tracking UI System? 0 Answers
(c#) Photon networking, get players in room? 1 Answer
4.6 UI Text rect does not expand automatically 2 Answers
Unity 4.6 button movement problem 1 Answer
[4.6 - UI] Keep aspect ratio 2 Answers