Corona performance?
Asked Answered
M

6

7

I and my team are developing a game using corona sdk, our game is supposed to work on both iphone and android devices.

When testing with android sdk 2.2 the performance seems to be poor, although we are following all the memory management steps and avoiding leaks, regarding global variables, timers, transitions, display objects, etc.

Does anyone have an idea about such performance issue? When searched across the net most said that it is a bug within corona itself.

Messuage answered 23/10, 2011 at 12:53 Comment(4)
...testing on which Android devices? Because a game that runs well on an iPhone 4 may not run so well on a HTC Wildfire, due to the difference in hardware alone...Inconsequent
we were testing on galaxy s device , we haven't tested on iphone yetMessuage
It is a known fact that Corona has bad performance on Android compared to iOS. There's little you can do about it. The situation is improving a bit in the latest daily builds, but nothing spectacular. If you look around in the Corona forums you can see a few threads talking about it. The official response is always that "Android is fragmented and we can't help you unless you file a bug report with a code sample demonstrating the problem and the device affected".Trenton
Do you use the physics engine? It will get very slow very fast if you have "too many" physics objects.Tessy
S
3

Besides memory leaks, you want to make sure your graphical (and audio) assets are well handled. Keep texture memory low and optimize by using sprite sheets over individual image files. More importantly, keep the image file sizes as small as possible, and remember that once in memory the size of the image file isn't what's important, it's the dimensions (once loaded, the image is stored as a texture, independent of compression.)

Make sure you display.remove() sprites and images.

That said, after some tweaking of our own Corona game, performance was fine.

Seadog answered 17/1, 2012 at 22:57 Comment(0)
D
2

I dont know how it is on android, but Im developing with Corona for iPhone and I dont have this problems...

Make sure you remove all objects, stop timers, nil variables, remove event listeners... and clean memory on every scene change.

Here is a good post about memory leaks and performance: Corona SDK Memory Leak Prevention 101

Dyan answered 23/10, 2011 at 13:21 Comment(2)
thx networ but we did remove objects , timers and listners but seems that it is another issue , the fact is that we have large number of objects moving through transition.to ,, but i don't think that this could be the reason for such poor performanceMessuage
Did you test your app on iPhone? Because it can be really bug, but if there will be poor performance on iPhone too, it will be probably some memory leak in you app...Try this: local monitorMem = function() collectgarbage() print( "MemUsage: " .. collectgarbage("count") ) local textMem = system.getInfo( "textureMemoryUsed" ) / 1000000 print( "TexMem: " .. textMem ) end Runtime:addEventListener( "enterFrame", monitorMem ) And if you memory with every restart or scene change goes up it something wrong...Dyan
S
1

I haven't noticed any performance issues on Android 2.2, even with relatively large images and sprite sheets. With large numbers of physics objects, maybe.

The only bottlenecks I've encountered were the number of screen objects displayed. For example, in level selection menu, where each level has its own button with text over it. But that was over 200 of display objects and was still decent in term of performance with a slight FPS drop during swipe animation.

Another case was with elastic snake, where I had an algorithm detecting self-intersections in every frame and flood filled the enclosed area (if there was one) line by line. That was very expensive, but Corona doesn't have a function for drawing complex shapes, only primitives. So that was the only option.

So it all depends on what you do with it. Corona is great for most things, but not all.

Shala answered 2/6, 2012 at 19:53 Comment(0)
P
0

In my experience, performance on Corona for Android lags way behind comparable Corona projects for iPhone, even when optimization efforts are made -

This issue is echoed by those on the Corona forums - http://developer.anscamobile.com/forum/2011/04/20/terrible-performance-samsung-galaxy-s-crashes-tegra-devices

Poore answered 26/6, 2012 at 19:34 Comment(1)
Please quote the relevant parts of the link in your answer, which ideally should be self-readable :) (link rot, referencement, etc.)Vallombrosa
S
0

I have an app, http://itunes.apple.com/app/rocket-space/id531141378
It works fine on any iOS devices and shows 60FPS even on iPhone 3GS.

But on android, I have 10-15 FPS, even on top Android devices with Tegra 2.
Amazon Kindle Fire works better, but not so smoothly as iOS, it shows only 19-23 FPS on device.
I tried to use different versions of the SDK, stable 704 and 840 and lot's of daily builds. But this doesn't help, I've got a perfomanse boost in 2-3 FPS on different versions, but it also left a bunch of restrictions to the code. I optimized the code wherever i can, cached bunch of variables, optimize onFrame calculation, but this doesn't help )=

So I think that Corona is very good SDK for developing iOS only projects, but not Android. As Corona is very bad optimized for Android. For our next gamewe decided to move to Unity.

Stemware answered 27/6, 2012 at 14:54 Comment(0)
C
0

I have faced the same issues regarding the memory management. Corona tell us that is you use Composer library , it will automatically handle memory & objects , But is Doesn't.

Try to remove each of your scene object Manually in Hide() phase & set that group reference to nil.

You can use the following code block to refer the memory leakage in you app/game.

Memory Leak: It is the concept of constantly increasing memory use because of unnecessary allocation of memory. Leak is said to occur as soon as memory in device is exhausted, any attempt to allocate more memory causes application to terminate itself or it will negatively affect the performance.

In corona following function can be use to check the memory allocation:

local function printMemUsage()

local memUsed = (collectgarbage("count"))/1000

local texUsed = system.getInfo("textureMemoryUsed")/1000000

print("\n---------MEMORY USAGE INFORMATION---------")
print("System Memory Used:", string.format("%.03f", memUsed), "Mb")
print("Texture Memory Used:", string.format("%.03f", texUsed), "Mb")
print("------------------------------------------\n")

return true

end

Runtime:addEventListener("enterFrame", function() collectgarbage("step") end)

timer.performWithDelay(2000, printMemUsage, -1)

There is a limit on the maximum texture size that a device will support. If you exceed this limit, the texture will automatically downscale to fit within the maximum. You can use the system.getInfo( "maxTextureSize" ) command to determine the maximum texture size for a particular device. See system.getInfo() for more information.

Memory Leak Prevention:

Avoid overloading the memory : Avoid loading too many images into one lua scene. Handling the globals: Don’t forget to unload the global variables. Mostly use local variable. Free up memory : Before switching to another scene remove all unnecessary timers, transitions runtime event listeners, display objects. Use the following method to free the memory- timer.cancel( timer_name ); timer_name = nil -- to remove timers transition.cancel( tran_name ); tran_name = nil -- to remove transitions display_object:removeSelf(); display_object = nil -- to remove display objects runtime:removeEventListener() -- to remove runtime listeners Dispose all audio files when they are no longer needed: audio.dispose(audio_name); audio_name = nil -- to dispose the audio files.

If you need to set or transition a specific property of several display objects to the same value — for example, fade an entire overlay menu to alpha=0 — it's better to add the objects to a display group and modify the property of the entire group. It's easier to code and it optimizes memory and speed.

While avoiding global variables and functions isn't always possible across the board, minimal usage is the best practice. Access to local variables and functions is simply faster, especially in time-critical routines.

-Thanks Assif

Cowans answered 7/11, 2016 at 6:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.