I've just run my game through Corona Profiler, and the overriding feedback is that the following line of code is horrifically slow:
do local g=snapshot.group local c=snapshot.canvas c:insert(blank) for i=g.numChildren, 1,-1 do c:insert(g[i]) -- <-- The offending line end end snapshot:invalidate("canvas")
I assume this is because both groups are changing size as objects are removed from one list and added to the other. As far as I can see, this could be solved by having an extra canvas mode in which objects from the canvas remain in the canvas group after the invalidate, or by having a single function to shift all items from one group into another (though beyond this use case where you want to return former canvas items to the group I can't see a use for it).
What am I trying to do? Basically I am trying to use the canvas to create a firework effect. So each frame I update the firework particles positions, fade the trails already on the canvas, add the particles back to the canvas and call invalidate. That last call chucks all the particles into the canvas's group, so next frame I have to fish them out again.
Can anyone think of any ways around this?