Cocos2d-x and Android

Hi,

I need to know what do you guys do to optimize a game for android. Are there any specifics? like texture sizes, Less number of animations, shaders and number of particles?

Currently for my game I get around avg 57+ fps on iphone 5 and 54+ on iphone 4S. There are no issues in IOS platforms.

But when I’m on android all sort of fps issues come even on the devices that are several times faster than iphone 5. Even on s6 the fps drops to 40+ avg and varies down to 30ish.

Should i have low res textures for android to optimize the performance? or should i remove all particles and effect. I’m not sure what to do here. And i don’t get why the performance on android devices significantly drop. Is it a problem with my way of coding, or the textures or cocos2d-x itself.

I did notice on my previous game that using runActions too much destroys fps on a samsung phone.
For my game spin it, ios gave a consistent 60fps but on samsung when i used runAction on several sprites together the fps dropped to < 10. But this game was made in cocosV2 so I’m not sure if this is now relevant.

Thanks

bump! i need help on this

are you using a Spritesheet?

yes, I am using spritesheets but, mostly spine is used for animations.

so the problem is with spritesheets?

A few things that come in my mind. See if you are spawning a lot of particles at one go. If you need to, disable all particles and observe the performance. If the performance does not take a hit, then high chance the particles are the culprit. At this point, you have 2 options, either you do away with the particles, or tone down the settings in the particles. One method which I always use is to reduce the max particles in the particle file, it does help with the performance.

Using a lot of textures should not affect your performance. However, if you are loading textures on the fly, then it will hit your performance, regardless high or low resolution. If you are preloading the textures before you run the game scene, then it should not hit the performance that hard.

Actions and spawning of a lot of objects at once will hit the performance as well. You might want to look into that as well.

Hope it helps

hey, Thanks for your help, but what i don’t get is samsung galaxy S6 and iphone 4S should not give the same level performance. S6 is almost 10x as fast maybe more.

Sorry for being annoying and bumping this again!

So, I removed all the particles and the backgrounds from the game, just keeping one background color. the fps is still an issue. Auto culling doesn’t seem to work at all… the enemies outside the screen are still consuming a draw call.

Are you use the spritesheet for animations only?

Yes i am using spritesheets for explosions and bullet hit effects… rest of the animations are done in spine

If you have many files with textures then try to combine them into one spritesheet, it should boost performance.

Okay will do that, but what i dont understand is why is there a big gap in android and ios performance. Is it because of this game engine?

I can not answer this question). But it interests me too.

@slackmoehrle hey, would you like to shed some light on this?

Do you have a test case that I can play with?

hey i think i have figured out whats causing it… let me just make a few tests ill report the bug.

alrighty. Please do.

I ran into some performance problems in my game around ParticleQuads, maybe something similar is happening here with other types of objects.

So Android has a GC that cleans up any memory that it thinks it can reclaim, causing “random” pauses. Any time you want to destroy something, DON’T. Don’t create or destroy things on-the-fly if you can help it.
Allocate everything you think you’ll need up front.

If you keep all instances in an Object Pool, you can grab an instance when you need it and avoid GC hits.

In my case I started pooling particles, just grabbing one from the pool and repositioning and restarting them whenever I need a “new” one, and as a result, there are less slowdowns, especially after the first particles are added and re-used.

*note the screenshot above was taken from an iphone, hence the 60 fps.

@slackmoehrle Sorry i wasn’t able to make a test project for you guys yet.

ParticleQuads are a known issue and seems to take the performance down on android. So i removed them but i have still have a fps rate of ~20. On s6 ~20 is really pathetic so i kept on removing stuff from my gameplay.

So it turns out Clipping nodes and stencils were the Major issue with the performance drop. Removing these takes the fps back to 60.

Im not sure if the progress timer or the ui::Slider has a role in this or not, but I will make further tests when i get free time.

In another scene with rain(a 10 frame sprite on a runAction(repeatForever)). Causes a major drop in frames. The whole sprite sheet is only 512x512 texture.

So basically on s6, estimated fps drops were.

ClippingNodes(using 6-8 in a scene) : fps drop ~30 fps
Particles( 30max particles): fps drop ~25 fps
Full Screen SpriteSheet Rain( 512x512 texture 10 frames): fps drop ~ 20fps

the things mentioned above have no performance issues in iOS and work perfectly with ~58 fps.

@Jgod I am creating & destroying a lot of sprites on-the-fly, this effects the android version a bit i guess i have to change A LOT of things. :slight_smile:

thanks for the help guys @Jgod @jjeorijjang

1 Like