- Home /
Lags during tests on mobile SpriteRenderer.RenderSingle
Hello! I am testing my 2D game on mobile. On Android LG2 mini I get very good results, but on Android Lg e430 (it's older phone but still - 512 mb RAM, 1.0 Ghz CPU) I get lags and FPS go down from 30 to 12-20. They are back to 30 after a while, but it shouldnt happen.
In profiler when I have my phone connected I see that SpriteRenderer.RenderSingle is abou 15 % and SpriteRenderer.RenderBatch is 5-20%.
I have one GameObject with SpriteRenderer and simple animation attached to it on the Scene + Background. Sprites are singleSprites and set them to Compressed 256/256 (I lose quality but I wanted to be sure what causing a lag...) I suspect that I did something wrong with Sprites... ;)
Answer by Ozan_2 · Sep 30, 2015 at 02:03 PM
Hi @kunmateo1993
Unity tries to force maximum resolution on builds. However, mobile devices have little screens so there is no need to force game to run HD or Full HD. Try to add one of your scripts' Start method this line:
Screen.SetResolution(480 , 600 , true);
You can change resolution values if you are not comfortable with these ones.
You can also set resolution dynamically by getting devices hardware properties (Like if ram is below some value, set resolution that value)
I hope it helps.
I set the screenResolution as you said. Unfortunetly still getting lags. I know that profiler consumes a little bit of fps but still it doesnt look good. And feel also no good... (as far as lags are really noticable)
Here is another test- I only changed Camera from skybox to depth...
@kunmateo1993 , did you try creating an empty project and build it for your phone? On the first screen shot, everything seems okay to me. $$anonymous$$aybe it is the phone itself cannot handle the application. If an empty project causes that kind of lag, there is no need to put an efford to optimize your game.
If the empty project works well on your phone, you should check out build logs. Build log is a really big file. You don't need to exa$$anonymous$$e all the file. Just find that line "Used Assets , sorted by uncompressed size:" Above that line, there are usefull stuff like how much ram is used by each mesh, animation, textures etc. I don't know if this is the solution but definelty it will help
Yep, I have just made a completly new project. Textures weight was 250 kb. On the scene I had one single sprite which could move with simple analog on touch.
Even when it wasn't moving it created lags. I also installed on the same phone two other games made with unity. Same thing - lags, aspecially at the begining of gameplay.
I guess LG E430 just has too weak hardware and that's it. It's a shame that I wasted 1,5 day for searching a lag-cause-ghost, but at least it wasn't 1,5 week ;) Thanks.
Answer by outasync · Oct 02, 2015 at 07:06 AM
@kunmateo1993
I have found that doing the following corrected lag issues I was having with Android devices:
Under Project Settings - Quality, make sure the profile being used for Android (Item highlighted in green) have V Sync - Every V Blank. For a simple 2D game you can use the Simple profile, by default Fast, Fastest and Simple have V sync to Don't Sync...which in my opinion for Android devices is wrong.
Under Project Settings - Player, make sure you have Android tab selected, go to Other Settings, Uncheck Auto Graphics API, and make sure only OpenGLES2 is added
Also make sure all your sprites are prefabed, more so if you use them more than once in your scene
I did what you said, I still get lags.
I downlaoded 3 other games made with Unity and they work in the same way on my poor device (LG E430) So I do not know how much of improvement your sugesstion gives
In that case I would suspect like you the device is just not up to the task. I have 2 new devices and since Unity 5 I experienced lag, I made huge optimizations to my game and it now runs a constant 60fps, I had hoped this was the case for you. Good luck with your project.
Thanks, if we talk about performance issues etc, I have one more case :
I am actually creating another project at home and when I go to the area where is more terrain and some sprites like trees, grass (2d Project also- platformer) my FPS goes down to 26/27. When I exit this area and go to the area where is less terrain ( I use Ferr2D Terrain Editor), actually you can see only a sky and some little ground I get 34-36 fps.
It is stange because I didnt set Application framerate to 30 or anything like that.
Before upgrading unity to 5.2 (when I was using 5.0.1) I got 57-60 fps. I will try use things you mentioned about qualitty settings etc, but do you know if unity autodetects mobile and doesn't allow to get more fps? On PC I had 55-60 fps.