Godot 4 Mobile Performance

Godot Version

Running on Godot 4.7.1 with C# .NET 8.

Question

Hi everyone. I have a 2D game that is a infinite side scroller. And I have been experiencing some performance spikes on mobile.

At first I know what to blame. My Generator class for the infinite map generation. I have the game divided in to chunks which contain logic and objects positions to generate a different map depending on those configs. And the way I was doing it was each time a new chunk was added I had to instantiate it as well as all the objects inside, then run the logic and then add to the scene tree. And this generated some frame spikes.
So I changed my approach. Created a plugin which converts my chunk levels from the Godot editor to a json file. And when the game is running it, it creates only 3 template chunks and moves them around. So we don’t need to instantiate a new chunk every time. Then created an object pool that I load on the start of the game, where I grab the objects that I need, change them, add them to chunk, and then go back to the pool. So that we don’t have to instantiate all this objects every time.
Ounce I did this the performance improved. However the spikes didn’t.

I even turned of the generator and left the Player running alone without anything not even ground, only the background scrolling and the Player. And still get the performance spikes on Physics Frame. In this image you can see clearly what I mean i had a 67ms spike with only the Player and the Background scrolling.

So I’m pretty sure I’m doing something wrong. No way Godot has this bad performance. I did the exact same game in the Construct3 engine it was way more complex already I used my custom engine to do it under C3 didn’t used any of it’s physics and the game ran very smooth when exporting with Cordova. So I expected that with Godot 4 the game would ran way way smoother. But so far is the opposite. And after I read some comments online mentioning Godot bad performance on mobile. I got a bit scared xD.

Some info that can help you guys:

  • The game is in 2D.
  • The game is using pixel art with a 380x180 base resolution.
  • The textures are optimized for 2D.
  • I’m using C#
  • I couldn’t pin point the issue yet.
  • The game runs at 60fps easy the phone that I use to test is a Legion Duel Phone 2.
  • The problem is not the FPS is the stability sometimes I get some big spikes on performance that are noticeable in game.

Does anyone have any idea of what could be causing this ?
I can give any info that you guys need.

Thank you

Small update on this. I just created an empty project on Godot 4.7.1.

Made some changes for mobile:

  • Rendering Method: gl_compatibility.
  • Import ETC2 ASTC: True
  • Display > Window > Size > Mode: Set to canvas_items
  • Display > Window > Size > Aspect: Set to expand
  • Application > Run > Max FPS: Set to 60
  • Physics > 2D > Physics Engine: Set GodotPhysics2D

And i still see some spikes now on Process Time. There are still spikes on Physics Time but they go to a max of 5ms that’s reasonable. But the Process Time seems too much for a game with only a Node2D. Maybe is something wrong with my mobile device ?

It would be really nice if we knew what “mobile device” meant. There are thousands of different mobile devices out there. Can you tell us the specific device you are using?

Its on the first post Legion Duel Phone 2, Android.

Are you using a custom export template or just the official ones?
Also have you tried using a different phone to see if the problem is still there?

Yes, I’m only using the official export templates. I even deleted them and downloaded again just to make sure.

There were 2 things that helped:

  • The Legion Phone Duel runs at 144hz so I set the maximum FPS to 60 end helped a lot dropping the Process Time.
  • The cable that I was using was not the best Android Studio told me to change I did, and it improved a little bit.

I tried with the new Test project that I created and with an Android tablet (Samsung SM-P613) that I had. It has a bigger screen and it’s suppose to be way worst then the Legion Phone so the difference is noticeable. As you can see bellow the Process Time is always on the limit and sometimes spikes over the Physics Frame Time.

I don’t think this is normal for a Project that has nothing. Can anyone help ? I don’t want to go back to Unity because of this :sob:

After some time working around with some settings on an empty project of Godot 4.7.1. This was the best that I got running on my phone. Which in my view this is bad for a game that is doing nothing. We can see spikes of 7ms when the budget is 16ms, just by doing nothing. I also see spikes of 4ms in the Physics Time which is not that big, but still, this is just a project that I created with only a Node2D. No scripts, 1 scene, nothing else.

Where are these spikes coming from ?

By the way this only happens when running on a phone, I tried 3 different Android devices all of them have the same results. Also tested my game on PC and runs at around 3500 FPS without any spikes. Some here and there but nothing special.