Performance: Android vs. iOS

Okay, I bought a second-hand HTC Desire and it took less than an hour to build our game (http://canupa.com/products/parallax) for android and run it on the device. That’s a good thing :slight_smile:

But unfortunately some issues came up:

  1. have some problems regarding custom fonts. I’m aware of the threads about this and I will check them out…

  2. scaling of images and text positions do appear different in the simulator and on the device. While my parallax scrolling looks nice in the sim (Nexus One template, which has the same resolution of 480x800) it jumps around on the device. Getting this right on the device is a hell of trial & error…

  3. sounds have a noticable latency

  4. and this is my main concern: PERFORMANCE! The game runs absolutely fluid on my iPod (2nd gen, 533MHz CPU). Why does the game lag on the Desire (1GHz CPU) every time an enemy or a bullet is spawn while there are no lags on any iOS device? Im using spritesheets and 2-frame-animations…

Generally, iOS builds are performing muuuuuch better on less powerful devices and run in the sim much more like they do on actual devices.

The question is: why?
And the second question is: what strategies do you recommend to gain similar performance on android and iOS devices?

-finefin

[import]uid: 70635 topic_id: 13777 reply_id: 313777[/import]

wait… I just created a little benchmark using my particle engine. And surprisingly the HTC Desire performs slightly better than the iPod touch !

so… where are the lags coming from?
I’m beginning to suspect the audio engine…

I prefetch all game sounds in a table and call the sound key…

local GameSounds =   
{  
 ["snd1"] = audio.loadSound( "snd1.wav" ),  
 ["snd2"] = audio.loadSound( "snd2.wav" ),  
 ["snd3"] = audio.loadSound( "snd3.wav" )  
}  
   
function playSnd(sndKey)  
 local sndChanFree = audio.findFreeChannel()  
 audio.play( GameSounds[sndKey], { channel = sndChanFree } )  
 return;  
end  

I found that snippet somewhere here in the corona forum and as it’s working great in iOS I thought that approach was a good idea… does that also apply for android?
[import]uid: 70635 topic_id: 13777 reply_id: 50610[/import]

it really drives me nuts!
I diabled everything. Sounds, background animations, collision detection…

if only touch controls, autofire and spawning enemies are running there still are significant frame drops.

so I also disabled enemies and I must say: performance still sucks, framedrops about once a second.

I can’t believe that it’s just my lack of LUA kung fu, 'cos it runs very nicely on iOS devices…

arrgh!
EDIT: wow. improvement! kind of… I disabled the text objects (score etc.) which updated on every frame. that gave the app a significant performance boost. is there a better way to display/update text than display.newText() ? [import]uid: 70635 topic_id: 13777 reply_id: 50701[/import]

Are you running your app at 60 or 30 fps? If you are running at 60 and don’t mind losing some smoothness you could try changing to 30 and see if that helps. I have found that the performance gain can be significant. I had an app that ran choppy at 60 but buttery smooth at 30. [import]uid: 27965 topic_id: 13777 reply_id: 50753[/import]

hm no. the app runs at 30fps.
I mean, it would be nice if it would… [import]uid: 70635 topic_id: 13777 reply_id: 50763[/import]

I’ve found no way to escape the audio delay on Android, but it’s best minimized by using the older Corona Event Sound API ( media.playEventSound ) than the new OpenAL one ( audio.play ).

I have not seen a noticeable difference in visual rendering between my iOS devices and Android. Responsiveness on the interaction/display side of things seems about the same, although some devices have a multitouch limit of 2 fingers. [import]uid: 4596 topic_id: 13777 reply_id: 50771[/import]

@singh206 what device do you have? [import]uid: 70635 topic_id: 13777 reply_id: 50774[/import]

What does your config.lua file look like? [import]uid: 27965 topic_id: 13777 reply_id: 50776[/import]

config.lua

application = { content = { width = 320, height = 480, scale = "letterbox", fps = 30, antialias = false, xalign = "center", yalign = "center" } } [import]uid: 70635 topic_id: 13777 reply_id: 50779[/import]

I changed the audio engine so it plays sounds with media.playEventSound instead of audio.play when run on an android device. unfortunately the latencies are the same… :frowning: [import]uid: 70635 topic_id: 13777 reply_id: 50845[/import]

Hi,

I’ll throw in my 2 cents regarding some of your questions :

  • Fonts need to have “simple” names inside the TTF file (eg had to rename j.d. in jd and “whatever 1” in whatever1) for those to load on android.

  • Regardless of it being a one year old high end device, the Desire has quite some performance issues usually (not regarding Corona)

  • I use an iPod 4th and a Desire for my tests, what I saw is that the Desire takes a lot of time loading ressources (either audio or graphics), my intuition is that memory card is slow. But when things are loaded, things go pretty smooth regarding either hires sprites or physical engine. Didn’t check the exact framerates, but they labout the same on both devices.

  • We use the new sound API, with preload as you stated in your message

  • text may be a good track, since I remembered that when starting up with Corona a few months ago, adding a FPS display string had the Desire almost stop.

Hope this helps,

Phil [import]uid: 51301 topic_id: 13777 reply_id: 51136[/import]

dev89, thank you that’s really helpful :slight_smile:
anyhow, I will focus on the latest version for iOS for now.

but I’d like to test my game on different android devices…
so if anyone here with a different device than the Desire is willing to test, please contact me:

finefin at googlemail

cheers [import]uid: 70635 topic_id: 13777 reply_id: 51252[/import]