Android: Programming for performance: Do's and Dont's

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By cgeadas

I’m starting to try my new game on other android devices than my own and I’m very disappointed with the performance. What I think is a simple 2D game is struggling with stuttering and low fps.
Since it’s my first Godot game, I’m assuming it’s due to poor programming choices and general ignorance towards Godot development, so I’m going to rewrite whatever I can to make it better, but I don’t know yet what makes it “better”.
So I’m asking this (and I’ve read the previous questions about this subject) hoping to get some guidance relating specific things, like “tweens, are they expensive?”, “resizing sprites, does it have real impact or is ti marginal?”, what are the usual fps killers? Are there instructions to avoid?
All and any advice is welcome.

See also here:

If you search that text for “mobile” you will find some info.

In case you exported game for the GLES3 renderer you should absolutely try out the GLES2 renderer. (Textures need to be compressed to ETC instead of ETC2 → etc compression has to be enabled)
See also

GLES2 requires less shader ressources which can make a difference on Android and PCs with slower graphics cards.

wombatstampede | 2020-03-10 15:47

never use light 2d in android , its very slow

supper_raptor | 2020-03-25 08:49

:bust_in_silhouette: Reply From: jgodfrey

While there probably are some general things to look out for, I’d suggest that you simply profile your game as it may have some unexpected peculiarities. Using the built-in profiling tools, you can determine where the lowest-hanging fruit is with respect to performance improvements.

IMO, there isn’t a lot of official documentation on the Godot profiler, but there are a number of other resources (including YouTube videos) that should be quite helpful.

:bust_in_silhouette: Reply From: Freeman

From my experience Godot is very fast on Android, but there are things that come to my mind:

  • not optimizing graphics;
    After I started to optimize/compress the graphic files, apks started to shrink significantly.

  • not compiling my own, optimized Godot engine. Maybe it’s not for a really new users, but at some point you will want to do that. In case of 2d games, just compile the engine without 3D component and without unused libraries baggage.

And from my own experince I would also add:

Hope it helps.

I found out, the hard way, that using tweens with fonts with outline works very bad on older phones - a frame taking 1,5 second to render.
Although it seems like an easy and cheap way to achieve very nice effects, it turns out that the best way to do it is by using pictures with the same tween effect instead.

cgeadas | 2020-03-26 16:27