[ Android ] Game running extremely slow

Thanks! The web based profiler gives better information but from what your screen it might be too much graphics to render.

Do you have lots of background graphics? Big textures in many layers?

Would you mind trying the web profiler as well?

Well, I have 2 sprites in the background.collection (for the background of course), each of them 144x256 .png images.

For the bird, I have 3 small 17x16 (pretty irregular) PNG sprites.
One animation ( with these 3 frames) in the game_sprite.atlas.

No at all!

( Beginners can’t post multiple images, so I’m dividing it in multiple posts )

Thanks a lot! If you click one of those large red frames at the top, you will get details on what happens there.

The red ones are frames where the game stalls. If you get a lot of those you may see a slowdown, or experience hitches.

It seems like your graphics is okay, but just to be safe. Try to remove all backgrounds and see if the game speeds up.

1 Like

In general you seem to have quite a good frame time anyway (<4ms at the selected frame), the spikes of 18ms is still almost 55 FPS. I don’t see any performance problem really, could it just be that some of your animations don’t depend on the frame delta?

1 Like

I rebuilt the project and clicked in the red bar, this is what I got:

After maximizing the window and running the profiler I got this:

As I said, when the window size is bigger, the game gets really slow. It’s worth mentioning that when it comes to Moto G the screen is smaller but the dpi is still high: 720 x 1280 pixels (~294 ppi).

It’s weird…

The VSync.wait in this snapshot means that the video card essentially is waiting for the previous frame to finish to avoid screen tearing, so not really a performance issue. As I said in my previous reply, I would suspect the game “feels slow” due to some inconsistencies with not using delta time when updating the animations. Are you updating animations/positions/rotations anywhere else?

1 Like

No, I’m not. If you take a look a line 26:

self.velocity.y = self.velocity.y + gravity * dt

I’m using the delta time to update self.velocity.y.

It works well on windows, with a 320x480 window, but when I scale the window up, or deploy to Android, the game runs slow.

Is there a way to include you in the list of developers, or make the project available so that you can mess around to find out what is happening?

I’d be happy to solve this. But anyways, you all have helped me a lot! :smile:

I made a little video to illustrate this…

The video recorder slows down the game a little, but you still can notice at 0:31 seconds when I change the resolution, the game starts slowing down a lot.

I really want to use this engine… I don’t know if I’m doing something wrong in the project configuration. I’d appreciate if any of you who already made any android game using Defold could make a simple tutorial on how to setup a project for android, with configurations and optimizations, because I think I have done something wrong, but I can’t figure out what.

Thanks again!

it should not behave like that. If you want, add me to your project and I’ll see if I can figure something out. My address is mikael@sicher.org

1 Like

A quick update; Strange, I just threw together a simple game object with your script but I can’t recreate what you are experiencing. Added a hacky elapsed-time-calculation from it starts falling to object reaches y<0 and it seems to report about the same time on Windows, OSX and iOS. I don’t have a Android to test on at the moment sadly.

If you would like to check this yourself, I added these to init():

self.start = socket.gettime()
self.start_pos = go.get_position()

And at the end of update():

if (pos.y < 0) then
	local fin = socket.gettime()
	print(fin - self.start)
	
	-- reset
	self.start = fin
	go.set_position(self.start_pos)
	self.velocity = vmath.vector3(0, 0, 0)
end
1 Like

Great! I got access to your project but you need to sync (File > Synchronize) to upload your changes to the server.

1 Like

Done.
I should have known this before. Sorry :smile:.

No worries. I’ve tested the game and can’t reproduce. No slowdown when resizing the game (on OS X). What OS are you running on? We’ll see if we can test on a Moto G2 as well.

OS: Windows 7 Ultimate
System type: 64-bit
Ram: 2,00 GB
Processor: Pentium® Dual-Core CPU E5400 @2.7GHz

I don’t know if it’s important too, but:

Could you run on a Moto G2? I’m really interested in solving this problem…

Hi,
Some additional suggestions:

You should be applying dt to your position addition (not so sure you want to apply dt to velocity like you do now, you can experiment with that). Likely, you’ll need to adjust your hard coded values (to larger) doing so.

Can you also check that on_message doesn’t get spammed with other messages because right now you are resetting velocity to -0.02 if the message isn’t “tap” and tapped == false. Do a simple printout or even easier, comment out the else … end velocity reset for testing.

1 Like