Performance Issues on Android Device

function Star:new(inputColor) local star = display.newGroup() star.name = "star" star.objectType = "star" star.x = math.random() \* W star.y = math.random() \* H star.starImage = display.newImage("Assets/star.png") if inputColor == "purple" then purpleStarGroup:insert(star) star.starImage:setFillColor(194/255, 52/255, 155/255) purpleStarGroup.movement = transition.moveBy(purpleStarGroup, {y=H, time=10000}) elseif inputColor == "gray" then grayStarGroup:insert(star) star.starImage:setFillColor(149/255, 149/255, 149/255) grayStarGroup.movement = transition.moveBy(grayStarGroup, {y=H, time=15000}) else whiteStarGroup:insert(star) whiteStarGroup.movement = transition.moveBy(whiteStarGroup, {y=H, time=20000}) end star.color = inputColor star:insert(star.starImage) star:toBack() --Physics -- local starCollisionFilter = { categoryBits = bitTable.star, maskBits = bitTable.screen} -- local starBodyElement = { filter=starCollisionFilter } -- physics.addBody( star, "dynamic", starBodyElement) -- star.isSensor = true return star end local function initParallax() for i = 1, 50, 1 do Star:new("purple") Star:new("gray") Star:new("white") end return true end

I am using this code to make a parallax space kind of background for my game. The app runs fine on the Corona Simulator and on my iPhone 5C. My app has no memory leaks (in fact it never goes over 1kb of memory use) and I have narrowed the background is causing my app to significantly slow when I run on my Samsung Galaxy Tab2 and Amazon Kindle Fire 1st Gen running Android. When I comment out the background, everything else in my app runs flawlessly at 60FPS, but leaving the background in causes the frame rate to drop to ~25-30 with no uptick in memory usage or texture memory usage. My config.lua file treats Android devices different than iPhone devices in terms of their screen size, everything else is constant. What could be causing this?

I think we will need to see your config.lua and the code where you load your background.

Rob

Init parallax is just called once in the enter scene method

--iPad if ( string.sub( system.getInfo("model"), 1, 4 ) == "iPad" ) then application = { content = { width = 360, height = 480, scale = "letterBox", xAlign = "center", yAlign = "center", fps = 60, imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } --tall iPhone elseif ( string.sub( system.getInfo("model"), 1, 2 ) == "iP" and display.pixelHeight \> 960 ) then print( "tall iphone" ) application = { content = { width = 320, height = 570, scale = "letterBox", xAlign = "center", yAlign = "center", fps = 60, imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } --iPhone 3,4 elseif ( string.sub( system.getInfo("model"), 1, 2 ) == "iP" ) then print( "small iphone" ) application = { content = { width = 320, height = 480, scale = "letterBox", xAlign = "center", yAlign = "center", fps = 60, imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } --16:9 Android elseif ( display.pixelHeight / display.pixelWidth \> 1.72 ) then print( "Android" ) application = { content = { width = 320, height = 570, scale = "letterBox", xAlign = "center", yAlign = "center", fps = 60, imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } --5:3 Android else print( "Android2" ) application = { content = { width = 320, height = 512, scale = "letterBox", xAlign = "center", yAlign = "center", fps = 60, imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } end

Here is my config.lua file

Can you try it with the transition.to() commented out on each of the stars? Looks like you’d have 150 transitions playing at once, a better way would be to put each type of star in it’s own group and apply the transition to the entire group instead of each start individually.

They are in groups already but your comment made me see that I am adding 50 instances of moveBy() to each of the groups, when I only inteded 1, which might be an issue.

I think we will need to see your config.lua and the code where you load your background.

Rob

Init parallax is just called once in the enter scene method

--iPad if ( string.sub( system.getInfo("model"), 1, 4 ) == "iPad" ) then application = { content = { width = 360, height = 480, scale = "letterBox", xAlign = "center", yAlign = "center", fps = 60, imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } --tall iPhone elseif ( string.sub( system.getInfo("model"), 1, 2 ) == "iP" and display.pixelHeight \> 960 ) then print( "tall iphone" ) application = { content = { width = 320, height = 570, scale = "letterBox", xAlign = "center", yAlign = "center", fps = 60, imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } --iPhone 3,4 elseif ( string.sub( system.getInfo("model"), 1, 2 ) == "iP" ) then print( "small iphone" ) application = { content = { width = 320, height = 480, scale = "letterBox", xAlign = "center", yAlign = "center", fps = 60, imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } --16:9 Android elseif ( display.pixelHeight / display.pixelWidth \> 1.72 ) then print( "Android" ) application = { content = { width = 320, height = 570, scale = "letterBox", xAlign = "center", yAlign = "center", fps = 60, imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } --5:3 Android else print( "Android2" ) application = { content = { width = 320, height = 512, scale = "letterBox", xAlign = "center", yAlign = "center", fps = 60, imageSuffix = { ["@2x"] = 1.5, ["@4x"] = 3.0, }, }, } end

Here is my config.lua file

Can you try it with the transition.to() commented out on each of the stars? Looks like you’d have 150 transitions playing at once, a better way would be to put each type of star in it’s own group and apply the transition to the entire group instead of each start individually.

They are in groups already but your comment made me see that I am adding 50 instances of moveBy() to each of the groups, when I only inteded 1, which might be an issue.