Codea 2.1 running code very slowly

Good news everyone. We found the source of the performance problems and fixed them. An update wil be submitted today or tomorrow (depending on beta testing).

That sounds good @Simeon, thank you, cant wait to get the update

@Simeon You the man!

@Simeon -


For anyone who wants to test the performance I have replaced the libraries used for Xcode export on our server.

So if you are experiencing performance issues please try exporting your project and building for your device — let me know if you get better performance (use a freshly exported Xcode project, otherwise the old libraries will have been downloaded from a previous build).

The 2.1.1 will be submitted shortly, and hopefully approved before the holidays.

I’m afraid to go off topic at this point but, is there anyone who’s willing to share its previously backed up version 2.0 of codea? Would it work to put it into itunes if the ipa is not mine?

ipad air ios 7.0.4 between 16 and 18 seconds instead of between 7 and 8 seconds
then twice as slow with the same ios

simeon thank you for your reactivity

@Simeon Thanks


Thanks Simeon for all your work, Codea is amazing !!
We are using it for our game (Penguin Breakout on the app store) and without Codea, the game wouldn’t have been possible …
With the 2.1.1 version, we are experimenting lower frame rates than with version 1.0, is it normal ?
On our main screen where we use a spine animation, on an iPhone4 (as an example) we dropped from 47fps to 30 (and sometimes lower). Same kind of issue with the game itself.
If there is anything I can do to help understand where the issue comes from, I would be glad to help …
Again, thanks for this great environment, keep up the good work !! :slight_smile:


(edit) Sorry for the typo, I think the version of Codea I was using was 1.5.5, I will check tonight and confirm.

@xdamon - for most of us, I believe the latest version resolves earlier speed problems.

So it will help Simeon if you can create some test code for him, that replicates the problem.

@xdamon There was a speed decrease from a previous version of Codea. I had a speed calculation program that I had on the forum. That program was use to show the speed back then, the speed decrease of an updated version of Codea, and then the speed back to normal on the latest version of Codea. That program was based on math calculations. I don’t think there was any program that did animations to show if there was a speed decrease or if there was a slow down, if the animation speed went back to normal. What would be needed is an iPad that has the slow version of Codea so the speed could be compared with the current version.


I am working with Xavier on the project and I experience the same issues. The code is quite big so we tried to narrow down possible causes. It seems the old gem mesh example reproduced a similar issue.

Luckily for this test I did not upgrade Codea my old iPad2. So I took the old example of the gem mesh, adapted it to draw 1000 gems and compared the fps between Codea 2.1.1 running on iPad Mini and Codea 1.5.4 running on a older Ipad2. Please note that in theory the code should run faster on iPad Mini.

So I get roughly:

30 fps on iPad Mini+Codea2.1.1

50 fps on iPad2+Codea1.5.4

So when playing with meshes and some Lua code there is an almost x2 performance decrease with 2.1.1!

@Simeon, @Ignatz, @dave1707 does this help ? I will paste the code shortly. Leave it running for 10 secs so the fps averages.

I calculated the fps by roughly averaging DeltaTime, if you have a better method please tell me.

Thanks for your support!


The code :

-- Use this function to perform your initial setup
function setup()
    -- A table to keep track of rectangles we add to our mesh
    rects = {}     
    -- We'll use this mesh to draw lots of gems on the screen
    gemMesh = mesh()
    gemMesh.texture = "Planet Cute:Gem Blue"
    -- Set the font for rendering instructions
    for i = 1,1000 do
    fps = 60
    t= 0

-- This function gets called once every frame
function draw()
    fps = fps * 0.95 + 0.05 / DeltaTime
    -- Dark background color
    background(20, 20, 40)

    -- Draw our gemMesh
    -- Adjust the rect positions in our gemMesh
    local pos
    local w,h = spriteSize(gemMesh.texture)   
    for k,v in ipairs(rects) do
        pos = vec2(v*2.5,0)
        pos = pos:rotate(t*v*0.5)
        pos.x = pos.x + WIDTH/2
        pos.y = pos.y + HEIGHT/2       
        local sc = (math.sin(v+t*5)+1)/2*0.35 + 0.65
        gemMesh:setRect(v, pos.x, pos.y,
                        w/2 * sc, h/2 * sc, t*5)
    -- Draw instructions
    text("fps "..fps,100,500)   
    -- Increment time counter
    t = t + DeltaTime * 0.1

function addgem()
    -- While dragging your finger, constantly add new rectangles to gemMesh
    local w,h = spriteSize(gemMesh.texture)
    local i = gemMesh:addRect(0,0, w/2, h/2)
    local c = color(0, 0, 0, 255)
    c.r = math.random(128, 255)
    c.g = math.random(128, 255)
    c.b = math.random(128, 255)
    gemMesh:setRectColor(i, c)
    table.insert(rects, i)

@oddcorrado I ran your code on my iPad Air (2.1.1) and iPad 1 (1.5.5). On the iPad Air, it ran at 59 FPS. On the iPad 1, it ran at 26 FPS. I then made a program that drew a lot of rectangles just to have another comparison. On my Air it ran at 7.49 FPS. On the iPad 1 it ran at 1.44 FPS. So I would say Codea 2.1.1 is running back to normal with meshes and rects. Like I said, I don’t have any old mesh or rect programs that were timed before and after the fix.

@dave1707, I would say the iPad1 has a very limited HW performance compared to an iPad Air. The performance decrease due to Codea 2.1.1 on the iPad air is probably “compensated” by the iPad1 much poorer HW performances.

We need to run the test on similar/identical machines with a different version of Codea.

I will try to run the test on an iPad Mini with Codea 1.5.4 so we can really compare.

Anyway on an iPad2 (poorer HW performances compared to iPad Mini) with Codea 1.5.4 it runs almost twice faster than an iPad Mini with Codea 2.1.1. It seems there has been some degradation (perhaps due to the new 2.1 architecture?).

Here are the results on my side with Corrado’s program:

46 fps on iPad mini + Codea 1.5.5

Corrado had the following with his config :

30 fps on iPad Mini + Codea2.1.1


I guess this is where @Simeon needs to see other times on more platforms.

Thanks @xdamon will profile this using your code

Thanks @Simeon ! :slight_smile: