Is UI ruining my fps on some of android devices?

Hi guys.

My game is very small, but have a lot of UI objects, I have somewhere 13-21 drawcalls in my game. Low triangles, using low textures, etc.

The game runs perfectly fine on Galaxy S7 (60FPS), but Nexus 10 tablet is unplayable (around 10-15 FPS)

I have now learned that some people after upgrading to Unity 5.x experience low FPS in their android games when using Canvas and UI elements.

The problem is my game is solely based on UI. I have one canvas and a lot of children to it. 90% of them are disabled at a time (GameObject.SetActive(false)) and when they are needed I enable them.

Could be this causing the problem? Last time I run the profiler - memory allocation was about for object count 32 MB.

EDIT: I found out that performace was improved by assigning a material with Sprites/Default shader to each UI Image (otherwise Unity would use standard shader, which is too heavy for mobile) - preformance on phones - galaxy s7, galaxy Grand Prime is awesome, but Nexus 10 tablet is not as good (it may be due to its too high resolution). I believe I can still improve it by choosing the right shaders.
What are the cheapest shaders for mobile - one very basic 2d and one with transparency?

I have finally solved the problem. Low performance in case of my game was caused by a few basic mistakes I made:

  • the most important one: I used to have several full screen images (some of them were used as a “flash” effect) - when they were needed their alpha was changing from 0-255. When their alpha was 0 I did not turn the gameObject off. This caused serious performance drop (they were invisible and they had to be rendered anyway and transparency is very expensive).

  • around 5 fps improvement when I turned off 9-slice sprite only on one button (with transparency).

  • leaving images material property empty - unity used default shader, which was much heavier for mobile

By fixing those issues I was able to increase performace up from 10-15 fps to 60 on Nexus 10 tablet (other devices were fine).

How often do you enable/disable gameObjects inside canvas? Note that canvas caches batches and it is so expensive to recalculate batches. Every time when you enable/disable gameObjects or change their transform or Image/Text properties, canvas recalculate ALL children. Try to separate you game between two or three canvases.

Note that not only dynamic batches count is important. It is also important how many CPU ticks are spend to calculating these batches. Try to profile your game. Who of two: CPU or GPU spend more time for each frame?

Raycast target also expensive. Try to disable it where you don’t need input.