Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Tremendous performance loss when building for Android
Started by tjackiw Nov 02 2010 11:30 AM

9 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

tjackiw

[GLOBAL: userInfoPane.html]
tjackiw
  • Observer

  • 25 posts
  • Corona SDK

I'm developing a game (fairly simple with a couple of screens and a few sprites) mainly for iOS but yesterday I decided to test it on an actual Android device (Nexus One) and there's a significant loss in performance compared to testing on an iPod touch.

I'm talking about 500-900 millisecond response time when the screen is tapped on Android compared to instant response on iOS. In addition, when I use logcat to see what's going on, it outputs things about "Grow Memory Heap".

Any idea why this is happening?

Thanks!
uid: 8446 topic_id: 3319 reply_id: 303319


[TOPIC: post.html]
#2

tjackiw

[GLOBAL: userInfoPane.html]
tjackiw
  • Observer

  • 25 posts
  • Corona SDK

I'm developing a game (fairly simple with a couple of screens and a few sprites) mainly for iOS but yesterday I decided to test it on an actual Android device (Nexus One) and there's a significant loss in performance compared to testing on an iPod touch.

I'm talking about 500-900 millisecond response time when the screen is tapped on Android compared to instant response on iOS. In addition, when I use logcat to see what's going on, it outputs things about "Grow Memory Heap".

Any idea why this is happening?

Thanks!
uid: 8446 topic_id: 3319 reply_id: 303319


[TOPIC: post.html]
#3

seanh

[GLOBAL: userInfoPane.html]
seanh
  • Plumber

  • 263 posts
  • Corona Staff

Can you give me a few more details.

What version of Corona are you using?
What is going on in your code when the touch happens?
uid: 3 topic_id: 3319 reply_id: 10165


[TOPIC: post.html]
#4

tjackiw

[GLOBAL: userInfoPane.html]
tjackiw
  • Observer

  • 25 posts
  • Corona SDK

Hi seanh, the structure of my project goes like this:

+ Main menu
+ Play
+ Game Screen
- Screen has one background image
- There's an init() method that creates the initial 4 enemy sprites and adds them to a table (enemyArray)
- The sprites have 4 frames each and they animate at about 600ms, and they contain an event listener on 'tap
- There's the game loop that moves the sprites and checks if they're "dead" and should be removed

-- Function when the sprite is 'tapped'local killEnemy = function( event )	if event.phase == 'began' then		local target = event.target		target.taps = target.taps + 1					if(target.taps >= target.tapsToKill) then			target.isDead = true		end	endend-- Main game looplocal gameLoop = function( event )  for i,obj in pairs(enemyArray) do  	if obj.isDead == true then  		table.remove(enemyArray, i)  		obj:removeSelf()  	else  		obj.x = obj.x + 0.10  	end  	if obj.x > display.contentWidth then  	  obj.isDead = true  	end  end  ...  end


I'm using the latest Corona Game edition by the way.

Thanks.
uid: 8446 topic_id: 3319 reply_id: 10183


[TOPIC: post.html]
#5

Eric

[GLOBAL: userInfoPane.html]
Eric
  • Contributor

  • 485 posts
  • Guests

There's another case where the # of screen updates increase when the screen is touched, but it sounds like this is different. I'll link this to that one so we look at them at the same time.
uid: 54 topic_id: 3319 reply_id: 10196


[TOPIC: post.html]
#6

jmp909

[GLOBAL: userInfoPane.html]
jmp909
  • Corona Geek

  • 1,328 posts
  • Corona SDK

is it ok to call table.remove whilst looping through that table?

uid: 6645 topic_id: 3319 reply_id: 10371


[TOPIC: post.html]
#7

Eric

[GLOBAL: userInfoPane.html]
Eric
  • Contributor

  • 485 posts
  • Guests

I'm not sure, but I don't see why not.

Is there a reason you don't simply remove the item in the function killEnemy()?
uid: 54 topic_id: 3319 reply_id: 11274


[TOPIC: post.html]
#8

tjackiw

[GLOBAL: userInfoPane.html]
tjackiw
  • Observer

  • 25 posts
  • Corona SDK

Thanks all, I've re-arranged the code around a bit and it now works as it should on Android.
uid: 8446 topic_id: 3319 reply_id: 11400


[TOPIC: post.html]
#9

Greg Squire

[GLOBAL: userInfoPane.html]
Greg Squire
  • Observer

  • 28 posts
  • Guests

tjackiw, Would you mind sharing what you did to rearrange your code, so that others could learn what to avoid for android builds? I've tried building several of the sample projects for android and all the physics samples were dreadfully slow on my TMobile MyTouch.
uid: 11021 topic_id: 3319 reply_id: 11854


[TOPIC: post.html]
#10

tjackiw

[GLOBAL: userInfoPane.html]
tjackiw
  • Observer

  • 25 posts
  • Corona SDK

Greg, nothing really specific to report, I just re-factored the way I was doing the main game loop and that seemed to fix the lag during gameplay on a Nexus one.
uid: 8446 topic_id: 3319 reply_id: 11932



[topic_controls]
[/topic_controls]