Performance: Why is Android worse than iOS?

Are you running any performance monitors on Android/iOS to see if the lua memory is increasing? Speaking from experience, I have had garbage collection running perfectly, but I have been using bad practices with variable maintenance. 

In addition, are you saying the game’s functions are slowing from being called, or the framerate is lowering?

I’m running a performance monitor inside of Corona.

https://developer.coronalabs.com/code/easy-use-performance-meter-memory-texture-memory-fps

Like I said, texture memory holds steady at about 10mb and the lua memory seems decent and consistent across platforms.

The framerate definitely takes a noticeable hit, and physics object motion starts to slow down to a crawl after about 15 minutes of gameplay. But the performance fluctuates a lot.

Almost all of my variables are local and are being disposed of when they’re no longer in use. I’ve made sure that I only have 6 physics objects on screen at any given time with simple shapes. I also make sure to remove physics bodies when they’re no longer being used (although I assume removeSelf takes care of that.). Reducing the physics iterations count doesn’t seem to help.

I also wrote debug code that will show the number of objects in any display group. This seems to hold steady around 30 objects at a maximum, and they’re all fairly small sprites. I use a lot of transitions, but I make sure to cancel and dispose of them when I’m no longer using them.

At this point I’m completely out of ideas on how to further diagnose any problems. The game runs great in the simulator and older iOS devices. It’s only newer Android devices that seem to struggle.

One idea, that will probably help… In my endless runner game i do not dispose of objects during gameplay.

I create a pool of objects at startup… When they go off screen i simply reset their properties and put them back off screen to the right. So there is no garbage collection been done during gameplay.

For me this has kept both framerate and performance top notch on both platforms and on weak devices.

That might help in general, but I’m still concerned that higher specs on an Android device performs worse than lower specs on an iOS device.

Again, speaking from experience, I’ve had a relatively strong Android device in the HTC Evo 4G crawl along with one of my games, while a 6 year old iPod Touch 3rd Generation took care of it with no problem. I even have a Nexus 4 that choke where an iPhone 5C excels. 

If you’re at the end of your rope, the only thing that has helped me is to strip my gamecode down to the bare essentials, plot performance, and start adding back elements, testing for memory leaks and framerate drops along the way. It’s certainly tedious, but it’s usually the only way to properly performance-test your code.

Yeah, unfortunately I have tried this. I removed all elements of the game until it was basically just a screen that moved from right to left. The game still had dips in performance, but only on Android and only periodically without any pattern that I could notice. The Android device gets fairly warm the longer it plays, even though not much is happening.

I may just have to accept that the Android version will be slightly less good. I can’t think of anything else to try.

Try changing/playing with the garbage collectors “step” cycle.

http://www.tutorialspoint.com/lua/lua_garbage_collection.htm

What you describe with periodic dips in performance sound like exactly what i was trying to say above. When the garbage collector kicks in, you are going to notice “hiccups” in fast moving games like endless runners.

I was using the performance script listed above to display collectgarbage(“count”) on the device when testing. The numbers it was displaying were consistent, rising at a modest pace and then falling when garbage collection kicked in. However, this didn’t seem to correlate with performance dips at all. I can’t see any pattern between the two.

Just to be clear, i’m not talking about memory usage here. I am talking about when the garbage collector kicks in and reclaims memory.

By doing collectgarbage( “collect” ) you are telling the garbage collector to kick in, and run one complete cycle of garbage collection.

Anyway, thats my 2c.

The ultimate solution to this issue is using an object pool that you reuse objects from, with no object remove/recreate cycles happening during runtime.

Take the advice as you will.

Cheers

Well, I assumed that displaying collectgarbage(“count”) is a good way to tell when garbage collection is actually occurring. The numbers increase modestly, and then dip back down to indicate that lua has collected garbage. However, when that dip occurs, it doesn’t seem to affect performance that much. When the frame rate is slowing to a crawl, the numbers are often low and still increasing modestly, so I don’t think garbage collection is the issue here.

I only explicitly call collectgarbage( “collect” ) at the beginning of a level.

Regardless, it still seems odd that this is only on Android, not on lesser iOS devices.

Are you running any performance monitors on Android/iOS to see if the lua memory is increasing? Speaking from experience, I have had garbage collection running perfectly, but I have been using bad practices with variable maintenance. 

In addition, are you saying the game’s functions are slowing from being called, or the framerate is lowering?

I’m running a performance monitor inside of Corona.

https://developer.coronalabs.com/code/easy-use-performance-meter-memory-texture-memory-fps

Like I said, texture memory holds steady at about 10mb and the lua memory seems decent and consistent across platforms.

The framerate definitely takes a noticeable hit, and physics object motion starts to slow down to a crawl after about 15 minutes of gameplay. But the performance fluctuates a lot.

Almost all of my variables are local and are being disposed of when they’re no longer in use. I’ve made sure that I only have 6 physics objects on screen at any given time with simple shapes. I also make sure to remove physics bodies when they’re no longer being used (although I assume removeSelf takes care of that.). Reducing the physics iterations count doesn’t seem to help.

I also wrote debug code that will show the number of objects in any display group. This seems to hold steady around 30 objects at a maximum, and they’re all fairly small sprites. I use a lot of transitions, but I make sure to cancel and dispose of them when I’m no longer using them.

At this point I’m completely out of ideas on how to further diagnose any problems. The game runs great in the simulator and older iOS devices. It’s only newer Android devices that seem to struggle.

One idea, that will probably help… In my endless runner game i do not dispose of objects during gameplay.

I create a pool of objects at startup… When they go off screen i simply reset their properties and put them back off screen to the right. So there is no garbage collection been done during gameplay.

For me this has kept both framerate and performance top notch on both platforms and on weak devices.

That might help in general, but I’m still concerned that higher specs on an Android device performs worse than lower specs on an iOS device.

Again, speaking from experience, I’ve had a relatively strong Android device in the HTC Evo 4G crawl along with one of my games, while a 6 year old iPod Touch 3rd Generation took care of it with no problem. I even have a Nexus 4 that choke where an iPhone 5C excels. 

If you’re at the end of your rope, the only thing that has helped me is to strip my gamecode down to the bare essentials, plot performance, and start adding back elements, testing for memory leaks and framerate drops along the way. It’s certainly tedious, but it’s usually the only way to properly performance-test your code.

Yeah, unfortunately I have tried this. I removed all elements of the game until it was basically just a screen that moved from right to left. The game still had dips in performance, but only on Android and only periodically without any pattern that I could notice. The Android device gets fairly warm the longer it plays, even though not much is happening.

I may just have to accept that the Android version will be slightly less good. I can’t think of anything else to try.

Try changing/playing with the garbage collectors “step” cycle.

http://www.tutorialspoint.com/lua/lua_garbage_collection.htm

What you describe with periodic dips in performance sound like exactly what i was trying to say above. When the garbage collector kicks in, you are going to notice “hiccups” in fast moving games like endless runners.

I was using the performance script listed above to display collectgarbage(“count”) on the device when testing. The numbers it was displaying were consistent, rising at a modest pace and then falling when garbage collection kicked in. However, this didn’t seem to correlate with performance dips at all. I can’t see any pattern between the two.

Just to be clear, i’m not talking about memory usage here. I am talking about when the garbage collector kicks in and reclaims memory.

By doing collectgarbage( “collect” ) you are telling the garbage collector to kick in, and run one complete cycle of garbage collection.

Anyway, thats my 2c.

The ultimate solution to this issue is using an object pool that you reuse objects from, with no object remove/recreate cycles happening during runtime.

Take the advice as you will.

Cheers

Well, I assumed that displaying collectgarbage(“count”) is a good way to tell when garbage collection is actually occurring. The numbers increase modestly, and then dip back down to indicate that lua has collected garbage. However, when that dip occurs, it doesn’t seem to affect performance that much. When the frame rate is slowing to a crawl, the numbers are often low and still increasing modestly, so I don’t think garbage collection is the issue here.

I only explicitly call collectgarbage( “collect” ) at the beginning of a level.

Regardless, it still seems odd that this is only on Android, not on lesser iOS devices.