- Home /
Full-screen background kills iPhone4 performance
Hi all, in my game I have a main menu scene with an image showing in the background. The image is relatively small, but resized in the editor to fill the entire canvas, whose reference resolution is 768 x 1024, for all iOS aspect ratios. With this setup the menu runs at about 5 fps on an iPhone 4, which becomes 30 fps if the image is disabled.
I've made many experiments, but the only other one that works is showing the background in its native size, which is rather useless as it fills only about one third of the screen. I've also tried rescaling the image to full screen size in Photoshop, to avoid in-game scaling, but it didn't have any effect. Importing it as a UI Raw Image instead of Image didn't help either. There are no transparencies in the whole scene.
So, I understand that the iPhone 4 has issues with large images, but is there any way to show a full screen image on this device without such a huge performance drop?
Answer by lugduweb · Jun 22, 2015 at 03:50 AM
How do you manage your image ? Is it a sprite or a GUITexture ? Is it compressed ? If not, you're probably filling the iphone men.
Do you have a shader attached to your background ? How do you compute and display your framerate ?
Answer by Xarbrough · Jun 21, 2015 at 11:25 PM
This shouldn't be the case. Are you sure there is nothing else going on? Have you tested a blank scene where you do nothing but place the image on a canvas?
Answer by gselfish · Jun 22, 2015 at 09:17 PM
First of all thank you guys for your input. The image is a 659 x 896, 16 bit / Truecolor (makes no difference performance wise) sprite. As I said I've also tried turning it into a compressed/uncompressed texture attached to a Raw Image, but nothing changed.
Additionally, I've set up a simple scene with OnGui buttons that allow me to:
Change the image size to native / resized to fill an iphone 4 screen / resized to fill iphone 5
Disable the image altogether
Disable the main menu panel (which basically leaves only the BG in the scene)
Change camera flags to skybox / solid color / none
Enable / disable alpha on the main menu panel (just to try... turns out it makes no difference)
The most relevant result: with the menu disabled, and native image size on a solid camera background, I get 30 fps. Resizing the image to full screen causes fps to drop to 16.
By turning on the menu, the fps drop to 17 and 11 respectively (with 12 draw calls). It's a huge drop, but I should also mention that if I turn off the BG and show only the menu, I get 25 fps. The menu I'm showing is very similar to this one (I'm actually using this store asset):
Btw, switching the camera from solid color to skybox also has a huge performance hit, even if the image is filling the screen. With everything on + skybox, I drop to 6 fps.
But again, I think the most important result is the drop I initially mentioned from 30 to 16 fps. Any idea as to how can this be avoided?
I faced with the same problem even single dot sprite ruin all performance. Here I show up one sprite (size 1x1 pixel) which is filling all screen
If I scale out the size, performance increase
The problem can be conform using any iPhone, Android devices and even PC, just increase amount of the full screen sprites in my example: "BlackTexture" using Ctrl+D (Command+D). To be able to control the scale in the project use one touch to decrease Sprite size and two touches to increase.
Example available here https://dl.dropboxusercontent.com/u/66011823/tmp/ScaleTest.zip