Game runs fine on simulator on Windows and iOS build on iPod 4g but crap on Android.

Hi,

As title says my game runs fine on simulator on Windows and iOS build on iPod 4g but like 5fps on Android. What can be the problem and where should I start to investigate?

Hi Aidin,

Are you using widgets?  There was a performance issue for widgets affecting Android devices discussed in this thread (http://forums.coronalabs.com/topic/34701-android-acting-really-slowly-simulator-and-ios-ok/page-2?hl=+android%20+slow) and addressed in daily build 1126.

If not, then what Android device are you using?  If it’s an older device, it may just be less powerful than the latest iOS devices, in which case your best option would be to optimize your code.  You can use a profiler tool like Corona Profiler to help figure out which areas of your code are taking the most processing time.

  • Andrew

My problem was not your case. Because I tried latest daily build and also 1126 that helped you, even I removed my only button that required widgets library, but still android builds are extremely slow on devices.

Would someone please shed some light?

iOS builds and game on simulator on both Mac and Win are OK and I tried 3 different devices so far, all somewhat new.

To answer your questions, I tried my game on a HTC Amaze 4G (also known as Ruby in some continents) and two recent Xperia phones. I believe all three devices are considered fast ones and then again, my game is nothing but 4-5 objects moving across the screen.

Can you look at the output from “adb logcat”?  This is the devices console log and it might have a clue what’s going on.  Can you put the .apk somewhere. I can try and install it and see what I see on my Nexus 7.

Solved.

Problem was the debug text I have on the background and was updating it on every frame. As I’ve read in Joshua’s post in another thread, text rendering in Android is heavy and I thought maybe it’s that those debug texts I have and it was it. Strange is, I was just writing like 7 lines of text each consisting of like 10 chars, apparently it’s still too much for it.

One more thing,

In my game objects move from top to bottom of the screen and at most there are like 6-7 display objects moving across the screen. Problem is I see random hiccups in Android. They are not severe but ruins the smooth gameplay experience for the player.

Any idea how to track this or what might cause this? I’m only seeing this in Android and game runs fine in iPod 4th gen.

@Rob:

Thanks man, I solved my initial problem but if you are still interested to help track this hiccup problem, let me know and I’ll upload my game for you.

(You deleted your post or it’s 5am and I’m mistaken that you replied?!)

I don’t think I deleted my post.

It’s my Internet connection that acts funny.

Do you have any idea regarding the hiccups in object movement?

I have three suspicious:

  1. I tied my HUD update call to enterFrame (maybe I should do the actual update every 2 frames.)

  2. I play a background music with this code:

    local music = audio.loadStream( “music.mp3” ) local options = { channel=1, loops=-1, } local musicChannel = audio.play( music, options)

(not sure if it’s the best way to play music on Android)

Anything else?

I know that on older devices like the Nook Color and the 1st gen Kindle Fire, sounds really dragged things down, in particular if they are 44khz stereo sounds.  Making them 11khz mono sounds really helps alot.

Depending on how much your HUD is updating, doing it every frame could be a big CPU hit.

Thanks for the reply, I do appreciate them.

I don’t believe my device test being slow, htc Amaze 4g’s specs are here.

I removed calls to HUD update and music playback but the stutter didn’t change a bit. Anything else comes to mind?

Please note that I changed fps to 60 in config.lua to have smoother gameplay experience.

(I also wanted to PM you a link to my game but apparently I can’t PM you here)

Hi Aidin,

Are you using widgets?  There was a performance issue for widgets affecting Android devices discussed in this thread (http://forums.coronalabs.com/topic/34701-android-acting-really-slowly-simulator-and-ios-ok/page-2?hl=+android%20+slow) and addressed in daily build 1126.

If not, then what Android device are you using?  If it’s an older device, it may just be less powerful than the latest iOS devices, in which case your best option would be to optimize your code.  You can use a profiler tool like Corona Profiler to help figure out which areas of your code are taking the most processing time.

  • Andrew

My problem was not your case. Because I tried latest daily build and also 1126 that helped you, even I removed my only button that required widgets library, but still android builds are extremely slow on devices.

Would someone please shed some light?

iOS builds and game on simulator on both Mac and Win are OK and I tried 3 different devices so far, all somewhat new.

To answer your questions, I tried my game on a HTC Amaze 4G (also known as Ruby in some continents) and two recent Xperia phones. I believe all three devices are considered fast ones and then again, my game is nothing but 4-5 objects moving across the screen.

Can you look at the output from “adb logcat”?  This is the devices console log and it might have a clue what’s going on.  Can you put the .apk somewhere. I can try and install it and see what I see on my Nexus 7.

Solved.

Problem was the debug text I have on the background and was updating it on every frame. As I’ve read in Joshua’s post in another thread, text rendering in Android is heavy and I thought maybe it’s that those debug texts I have and it was it. Strange is, I was just writing like 7 lines of text each consisting of like 10 chars, apparently it’s still too much for it.

One more thing,

In my game objects move from top to bottom of the screen and at most there are like 6-7 display objects moving across the screen. Problem is I see random hiccups in Android. They are not severe but ruins the smooth gameplay experience for the player.

Any idea how to track this or what might cause this? I’m only seeing this in Android and game runs fine in iPod 4th gen.

@Rob:

Thanks man, I solved my initial problem but if you are still interested to help track this hiccup problem, let me know and I’ll upload my game for you.

(You deleted your post or it’s 5am and I’m mistaken that you replied?!)

I don’t think I deleted my post.

It’s my Internet connection that acts funny.

Do you have any idea regarding the hiccups in object movement?

I have three suspicious:

  1. I tied my HUD update call to enterFrame (maybe I should do the actual update every 2 frames.)

  2. I play a background music with this code:

    local music = audio.loadStream( “music.mp3” ) local options = { channel=1, loops=-1, } local musicChannel = audio.play( music, options)

(not sure if it’s the best way to play music on Android)

Anything else?

I know that on older devices like the Nook Color and the 1st gen Kindle Fire, sounds really dragged things down, in particular if they are 44khz stereo sounds.  Making them 11khz mono sounds really helps alot.

Depending on how much your HUD is updating, doing it every frame could be a big CPU hit.

Thanks for the reply, I do appreciate them.

I don’t believe my device test being slow, htc Amaze 4g’s specs are here.

I removed calls to HUD update and music playback but the stutter didn’t change a bit. Anything else comes to mind?

Please note that I changed fps to 60 in config.lua to have smoother gameplay experience.

(I also wanted to PM you a link to my game but apparently I can’t PM you here)