Search Unity

Resolved The list of "What to do"s for a perfect performance in a Mobile Game

Discussion in 'Android' started by mfatihbarut, Oct 16, 2021.

  1. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,059
    Hi all,
    The things that really increase the performance of a mobile build that I found until now are below.
    But before start, I should add this. "DON'T let any gameobject (which has complex components on it) showing in Editor Inspector before pressing the Play button. Because it may cause unbelievingly slow performance that you couldn't even solve the reason. Editor try's to update its information in Play mode and honestly sucks to do it.

    Could you add yours, please?
    1- Instead of Mono using IL2CPP as compiler and Use Incremental GC
    upload_2021-10-16_22-1-35.png

    3- Fixed DPI
    upload_2021-10-16_21-57-29.png

    4- Just having OpenGLES3 and usage of Linear as Color Space, on the otherhand if you don't check "Auto Graphics API" game may crash in some devices and you really really don't want it
    upload_2021-10-16_21-58-55.png

    5- Being carefull with Layer interaction for Physics calculations
    upload_2021-10-16_22-4-29.png

    and also low Default solver iterations.


    6- Usage of a higher value for Fixed time steps (instead of 0.02)
    upload_2021-10-16_22-8-28.png

    7- Baked Lightning, being careful with Shadow distance and/or completely ignore shadows

    8- Camera Culling.

    9- Sacrificing Post Processing and Anti-Alising :confused::cool::eek::(:(:(

    10- Texture compression ASTC

    11- 2k bitrate 15 FPS videos

    12- Choosing shader. Yes Unlit is very performancy but it is also under my quality level. But with a right approach starting from the artist who makes the materials it can be a great choice.

    13- GPU instancing and get rid of specular highlight from material options. If it doesn't mess your model

    14- Mesh compressing. Be sure that rewrite enable is unchecked (unless you know what to do)

    15- Texture Compressing and resizing (512 or lowest acceptable) and actually producing textures not so much bigger than their usage size in game.

    16- Refactoring. After messing your game in the learning process with a lot of unnecessary stuff you put under assets folder, starting the project from the beginning with your new level of knowledge (if you dare :D)

    17- A Magical Word: OnDemandRendering.renderFrameInterval = 3; The result is unbelievable... but be careful your videos my flicker in that case you should back it to 0.

    18- Be sure to have right import settings for mp3 files. Example picture below messages.

    19- If you don't click something in UI be sure it is not "Raycast target"

    20- The amazing "Enter play mode options" check box...

    21- Just to increase working speed don't forget to use Preset manager which gives you a huge time because instead of changing imported picture audio fbx etc. settings every time, you just change the default preset (the picture of the menu is at the picture following messages).

    22- Usage of URP for mobile. For me it is inevitable because graphics are awesome and even post-processing is not needed.

    23- Burst compiler, really increase the performance

    and Constantly disturbing Unity team to make them aware that "Unity's Android Performance could be much much much better, why don't you also do some upgrades that other game engines do
     
    Last edited: Jul 31, 2023
  2. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,073
    I would be very careful when messing with FixedUpdate time step.
    Your physics might not be very stable, and frames of your moving bodies might start to be noticeable, in that case you might also reconsider interpolation of rigid bodies.
     
  3. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,059
    I can imagine but you should also notice that the performance increase is huge...
     
  4. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,073
    This is why I have not say not to do this, but to be careful.
    Also performance gain depends on how much dynamic bodies collisions you are doing.
     
  5. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,059
    it is a tower defense game with lots of bullets and their effects...
     
  6. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,059
    Default Solver Iterations.
    upload_2021-10-16_23-37-2.png
     
  7. yuliyF

    yuliyF

    Joined:
    Nov 15, 2012
    Posts:
    197
    .Net 2.0 - why? It's old version.
    C++ Master - is more profit
    Graphics API : OpenGL 3.0 - you will lost 10-15% users
     
  8. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,059
    I didn't say net 2.0 besides I am using net 4.0 now. But have no idea what do those mean :)
    C++ Master? What is it? I don't think I am willing to change my language from C#
    "OpenGL 3.0 - you will lost 10-15% users" if you say OpenGL 2.0 I think it is ok because if someone is using OpenGL 2.0 that means he is already not able to pay for my game.:p
     
  9. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,059
    And the 5. element OnDemandRendering.renderFrameInterval = 3; The result is unbelievable.
     
  10. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,059
    upload_2021-10-22_22-38-19.png
    Be sure to have right import settings for mp3 files.
     
  11. bellenmark

    bellenmark

    Joined:
    Oct 21, 2021
    Posts:
    3
    thanks for sharing such an amazing article and helpfull.
     
  12. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,059
    upload_2021-12-2_12-0-50.png
    important notice this caused problem with Playfab (ha ha but true)
     
    Last edited: Mar 6, 2022
  13. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,059
  14. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,059
    21- [BurstCompile] (each function instead of whole script (as far as I saw))
     
  15. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,750
    Why incremental GC? That causes bad performance. Incremental GC is in cases where you F***ed up and have a lot of Garbage generated, but the way to fix this issue is the avoid garbage.

    In fact, I think I have issues with most of the suggestions in this thread.
     
  16. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,572
    It is best if avoided, but if you do have garbage, it is better to have it spread over several frames than have a performance spike.
     
  17. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,750
    Yes, but you are paying a cost every frame to be able to do that regardless of whether your performance issues are related to Garbage piling up.

    If you don't have spikes caused the from garbage collector often enough for them to be a problem, you are making your game perform worse by enabling incremental GC.

    It's a checkbox that is really situational. It may be very beneficial in the exact situation it was designed for (which is, you have the garbage situation that is completely out of control), and it harms performance in every other situation.

    I don't see how it can belong in a list that presents itself as "here are a bunch of no brainers to do, to get good performance on mobile". Most of the items in this list have this issue in some extend, but I think this is the worst offender.
     
  18. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,059
  19. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,750
    Challenging your list makes me a hater?

    Okay. I guess I can stop biting my tongue.

    To any newbie that wants to make mobile game:

    This list F***ing sucks, don’t follow any of the points blindly, there aren’t significant performance benefits to be found here and there are multiple ways these can have weird side effects to your project you’ll have a hard time debugging.
     
    Last edited: Mar 8, 2022
  20. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,059
    that is completely wrong.
    Even one of the simple recommendations, Fixed DPI returns as a huge FPS increase.
    and ondemandrendering increases the performance 3x
    What do you except more?
    what you have done is only being smart pants.
     
  21. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,750
    Yes, reducing the resolution on high dpi devices might yield better performance on certain devices under certain conditions and with certain games. If the bottleneck is elsewhere, you are reducing resolution for no real reason.

    It’s good that these settings worked for your game and whatever test device you are using, but please do not present them as universal no brainers that everyone should do.

    I’ve said my piece, hopefully newbies reading this thread will also read my warnings and make their own decisions.

    Bye.
     
  22. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,059
    I just tried to NOT USE garbage collection. Then I forgot that I have done it. Then after a time (when my project grew) My editor started freezing it was awful and I couldn't find what was the problem. Then I remembered to look at Profiler then I saw that huuuuugeeee GC spike in it. Then I enabled incremental GC again. and al problem solved.
    But it was very very bad experience. Therefore I really kindly ask you to not answer any questions in this forum. Because your answers hurt people
     
  23. mfatihbarut

    mfatihbarut

    Joined:
    Apr 11, 2018
    Posts:
    1,059