Horrible android performance :(

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

I have clone flappy bird, but the frame drop frequency on Godot 3.0.6.

On PC, I have to set FPS 120 to get smoother, but on Android, it very lags, how to set higher FPS on Android.

It’s just simple game, not many effects, but sadly, performance not good enough.

Did anyone experience this? Or know how to fix this? I don’t use scrolling background or animation… the fixed process doesn’t contain much code too… just a simple game that takes 10 mins to make… and has a horrible performance…

The source code looks like this link, pls check:


Video _ see the bird:

what about setting it to 60?

volzhs | 2018-08-30 07:01

It’s very lag at FPS 60 both PC and Android mobile

homaroxbk | 2018-08-30 08:56

You won’t get more performance by setting higher fps, on the contrary, it will affect performance.

Something may be wrong in the logic or the device (there are some gpu that do not handle Godot very well).

eons | 2018-08-30 11:09

:bust_in_silhouette: Reply From: MysteryGM

Hi, I profiled the games performance and discovered some problems.

First, I had the reverse problem, on my mobile it was so fast that it flew up over the pipes, with a single touch.

It looks like your touch code, is executing every frame. Instead you should maybe only check when the touch started.
You should use delta time, that way the game won’t work with frame rate but time instead.

	func flap(InDelta):
	bird.set_linear_velocity(Vector2(bird.speed , bird.linear_velocity.y - 100 * InDelta))

When ever you then call the function you pass Delta to it:

	func update(delta):

	if Input.is_action_pressed("flap"):

See update() already provides you with delta time.
Delta time, is the time it took to get from one frame to the next. So if your game is 60FPS then Delta will always be 0.016ms.

Your game is also using 160mb of memory. This is bad for very old mobiles, but not a problem for new ones. Because mobiles share memory between graphics and everything else. A sprite sheet could fix this.

I hope this helps.

1 - I reset the FPS to 60. Is there any setting that I have to notice?
2 - In my Flying State - the stage at beginning of the game like the video above. It do not have any code in func update (delta). But you could see, the bird not smooth and lag sometimes.
3 - How to check memory in Android while running game? I can check the version on PC by the system monitor but I am not sure it same as the Android version. And Android Studio cannot find my device when I using Godot.

homaroxbk | 2018-08-31 02:43

1.) If your frame rate is back to 60 then everything should be fine. All you need to do now is make the game frame rate independent.
The only other setting that can effect frame rate is V-sync. It should be on by default.

2.) Profiling on the PC should still give you stats, these won’t be accurate but can work as a rule of thumb, kind of thing.

Enable the developer function on your Android to see the stats of the device. That way you can see how much resources you have to work with. How to get developer options on your Android phone | Digital Trends

3.) If android studio can’t find your device then it could be too old. I have 2 mobiles that fell off the supported list with the last update.

Using a older SDK could help. But isn’t needed. Like I said earlier, profiling on the PC should give you acceptable memory measurements.

All you need now is to learn how to use the Delta value. I will try to explain it.

MysteryGM | 2018-08-31 09:47

:bust_in_silhouette: Reply From: MysteryGM

This is a explanation of how Delta works. So that you can see why it will give you frame rate independent movement.

When the game is running smoothly it should look something like this:

See every frame the object moves +1 to the side. So it moves 60 steps smoothly in 1 second.

However now the game is run on a weaker device:
Now because the game is only managing to render 12 frames per second, it can only move 12 steps. But the steps also look jagged. So we are moving less and very erratic.

To fix this we, get the time each frame took to render. This is known as Delta:
By multiplying the time it took to render, we can see how much the object had to move in the time while the image rendered.
We then move the object by that much, creating the illusion of smooth movement even if the frame rate is erratic.

I hope my explanation here is useful.

I see Godot has move_and_slide() that does this for you.

Thank you for your supporting.
I can understand the theory. So I tried by changing like this:

func flap(inDelta): 
   bird.set_linear_velocity(Vector2(bird.speed*inDelta, bird.linear_velocity.y - 5*inDelta))

Then update speed

var speed = 50*60

But it’s still lagging with high speed. The lower speed is ok. Could you try this on Android?
My devices are Samsung S6 and Samsung Note5
Now, I change it to KinematicBody2D. Longer code but it’s easier to control.

  • Sadly, KinematicBody2D with high speed has the same problem too. Now I do not know how to move quickly without change speed :frowning:
  • I have just changed the game style. Moving Pipe instead of the bird and it’s working well.

homaroxbk | 2018-08-31 21:51

:bust_in_silhouette: Reply From: homaroxbk

I uploaded the new app here:

My devices can play Real Racing 3 smoothy, but this not as good as I expected.
I really like Godot and hope that I can find the best way to fix it.

Impossible to play even on my Mac (using HTML version). The vertical lift is way to fast and when mouse or touch is released it does not drop fast enough.

wyattb | 2018-09-07 19:36