Codea 2.3 Beta

13

Comments

  • SimeonSimeon Admin Mod
    Posts: 5,362

    Apologies for the big jump in build number (38 -> 41). iTunes Connect has been having problems and it forced me to upload quite a few builds that got trapped in "Processing"

  • dave1707dave1707 Mod
    Posts: 8,387

    @Simeon The stretched image with different orientations is OK. The saveText and readText is OK.

  • Posts: 2,042

    @Simeon, readText now works which is great, and I'm not seeing the multiple copy buttons either.

  • Posts: 2,042

    @Simeon, a question about saveText: are they saved to the project or locally. What I mean by this is if I have an app and I push a new version, are the files saved with saveText replaced?

  • SimeonSimeon Admin Mod
    Posts: 5,362

    Thanks for the feedback @JakAttak and @dave1707, this seems like it could be the final 2.3 release.

  • Posts: 688

    @Simeon - didn't want to post this in a new thread as I'm running the latest 2.3 (41) build, but I noticed some weirdness with memory allocation / garbage collection that I wanted to get some feedback on...

    -- GarbageTest
    function setup()
        print("Garbage Test")
        --collectgarbage()
    end
    
    function draw()
        background(50,0,0)   
    
        translate(WIDTH/2,HEIGHT/2)
        fill(255,255,255)
        fontSize(40)
        text(collectgarbage("count"),0,0)
        --collectgarbage()
    end
    

    Run the above and (on my iPad 3) I get a starting figure of about 528k that keeps increasing, I get the fact that the string returned from collectgarbage() will actually require some allocation but it seems to increase at a significant rate (several k per second)

    Automatic garbage collection kicks in very sporadically (if at all - I've had the above run for a good 2-3 mins with an increasing counter that got up to over 1mb of allocated space).

    If I uncomment the first collectgarbage() I get similar behaviour - but it starts at around 328'ish k

    If I uncomment the second call (inside draw) then the count remains rock solid at 283k (which is what I'd expect).

    I know there is some kind of set interval code to control when automatic GC is run, but I was wondering if it was working.

    Also would it be worth adding an explicit call to the GC behind the scenes in the run time when setup() is complete?

  • SimeonSimeon Admin Mod
    edited March 2015 Posts: 5,362

    @TechDojo I think that's OK. Lua will determine when to do garbage collection, and Codea will force a gc when iOS triggers a memory warning.

    For me, your example gets up to about 800K then drops down to 500K and hovers there, occasionally collecting once in a while.

    It's better to let Lua decide when it's optimal to garbage collect, forcing it will hurt performance.

  • Posts: 688

    @Simeon - fair enough I just wanted to mention it incase it was relevant :)

  • SimeonSimeon Admin Mod
    Posts: 5,362

    Just want to say thanks to all of you for your great feedback and testing. Codea would be no where near as good without all your help.

  • Posts: 1,595

    @Simeon neither would it if it wasn't for your dedication so thank you and the rest of the team for all your hard work.

  • Posts: 398

    Well done @Simeon - another great release in the offing ;-)

  • Posts: 688

    @Simeon, I agree with the others, it's you that should be getting the thanks for all your hard work in making Codea the amazing app it is.

  • IgnatzIgnatz Mod
    Posts: 5,396

    @Simeon - I've had so much fun the past two years, I don't know how to thank you

  • Jmv38Jmv38 Mod
    Posts: 3,295

    ^:)^ ^:)^ ^:)^

  • Posts: 547

    @Simeon codea has been THE thing which has helped me learn alot about coding, I was a total noob, didn't know what classes were etc, thanks to codea, I'm now able to make decent programs (though not as complicated as someone like dave or ignatz, ... could do)

    So thank you and all of TLL for making and maintaining this amazing app <3

  • toffertoffer Mod
    Posts: 151

    Yeah, a big thanks to you TLL to have build and constantly improve Codea. You guys rocks!

  • Posts: 688

    @Loopspace, @Ignatz - Apologies if I've already missed this, but I just downloaded the 3D Shape library with a view to playing with it in the latest beta and it's falling foul of Lua 5.3 (mostly to do with variable args). Do you have an updated version that works with the new setup or would it be easier if I fix it and submit the code for review?

  • Just found this really annoying bug. If you go into settings and put zoom on, and put the low light filter on, when you go onto codea, the screen randomly flickers black. It's not only on the beta.

  • Posts: 2,161

    @TechDojo Loopspace can't read this thread as it's in the Beta testers category. The 3D shape library has been updated to run in the beta, I'll see if I can prod loopspace to post the update to github.

    Oh, hang on. I just looked at the code and I think that it is only the discreteNormal that uses the ... stuff. Try replacing that function with:

    function __discreteNormal(a,o,...)
        local arg = {...}
        local n = #arg
        local na,nb
        na = vec3(0,0,0)
        for k=2,n do
            nb = (arg[k] - a):cross(arg[k-1] - a)
            na = na + nb/nb:lenSqr()
        end
        na = na:normalize()
        if na:dot(a-o) < 0 then
            na = -na
        end
        return na
    end
    

    and see if that fixes it.

  • dave1707dave1707 Mod
    Posts: 8,387

    @Simeon Is there a reason why spriteMode doesn't work before setup() anymore. It works before setup() in version 1.5 . Run this and the sprite doesn't fill the square. Uncomment the spriteMode in setup() and it fills the square. Also, image set and image get require an integer. You can't set or get the half values for the retina display.

    spriteMode(CORNER)
    
    function setup()
        --spriteMode(CORNER)          -- uncomment this line
        img=image(200,200)
        setContext(img)
        fill(255,0,0)
        rect(0,0,200,200)
        setContext()
    end
    
    function draw()
        background(40, 40, 50)
        sprite(img,0,0)
        stroke(255)
        strokeWidth(2)
        noFill()
        rect(0,0,200,200)
    end
    
  • @dave1707 - Found this thread from a while ago.

  • Posts: 688

    @Andrew_Stacey - Thanks, that works perfectly. I just assumed that @Loopspace was already in on the latest beta.

  • dave1707dave1707 Mod
    Posts: 8,387

    @Saturn031000 Thanks for the update. Apparently I missed it or I don't remember seeing it.

  • Posts: 1,709

    HI @TechDojo, @AndrewStacey,

    I noted the problem with the 3D library and resolved it with the following code:


    function __discreteNormal(a,o,...) local n = select("#",...) -- arg.n local na,nb na = vec3(0,0,0) for k=2,n do nb = (select(k,...) - a):cross(select(k-1,...) - a) -- (arg[k] - a):cross(arg[k-1] - a) na = na + nb/nb:lenSqr() end na = na:normalize() if na:dot(a-o) < 0 then na = -na end return na end

    Hope that helps.

    Bri_G

  • Posts: 489

    @Bri_G one for the profilers, I think, as to whether select is faster than creating a table.

    (I appear to be able to read the beta thread now. Thank you to whoever enabled it. And thank you to @Andrew_Stacey for alerting me to the issue with the 3D library.)

  • Jmv38Jmv38 Mod
    edited March 2015 Posts: 3,295

    @LoopSpace i am getting confused. I though you were a new ID for @AndrewStacey? Are you both 2 different people? :-?

  • Posts: 77

    For some reason textSize() has been causing a crash; this used to be a bug, but I thought it had been fixed.

  • dave1707dave1707 Mod
    Posts: 8,387

    @FLCode Do you have a simple example of code that crashes.

  • SimeonSimeon Admin Mod
    Posts: 5,362

    @dave1707 there should be image rawSet and rawGet which access in pixels, instead of points. I'll have to think about using how to re-enable spriteMode and other graphical style changes outside of setup.

  • edited March 2015 Posts: 77

    @dave1707, unfortunately my code is about 2000 lines long, but the crash comes from textSize being called many times during draw().

    Here's how it's being called:

    tpt = {}
    tpt.widths = {}
    tpt.textwidth = function(text)
        ---[[
        if text and type(text) == "string" and #text > 0 then
            if type(tpt.widths[text]) == "string" then
                return tpt.widths[text]
            else
                --saveProjectTab("Log", "-- " .. type(text) .. " " .. text .. ": " .. table.concat({string.byte(tostring(text))}, ","))
                local x, y = textSize(text)
                --saveProjectTab("Log", "--textwidth")
                tpt.widths[text] = (x)
                return x or 10
            end
        end
        return 0
        --[=[
        --]]
        return 0
        --]=]
    end
    
  • dave1707dave1707 Mod
    Posts: 8,387

    @Simeon The rawGet and rawSet commands work, but you just have to remember to use double the value because of the raw size.

  • dave1707dave1707 Mod
    Posts: 8,387

    @FLCode I'm not sure what your code is doing, but you said you call textSize many times with draw. So I set up this code that calls textSize and increases the size of str by 1 character per draw. I can run this and let it go with no problems. Apparently the max textSize is 19997. So I don't think there's a problem with testSize.

    function setup()
        str="a"
    end
    
    function draw()
        background(40, 40, 50)
        w,h=textSize(str)
        text("Size  ".. w,WIDTH/2,HEIGHT/2)
        text("Length   "..string.len(str),WIDTH/2,HEIGHT/2-50)
        str=str.."a"
    end
    
  • SimeonSimeon Admin Mod
    Posts: 5,362

    @dave1707 a more future proof way would be to use x * myImage.scale, y * myImage.scale (iPhone 6+ has a scale factor of 3x, for example).

  • dave1707dave1707 Mod
    Posts: 8,387

    @Simeon I didn't see scale in the documents for image. I know about rawset and rawget for tables, but rawSet and rawGet for graphics are new to me. I'm just wondering how many other commands are available that don't show in the docs and how can we find out about them.

  • SimeonSimeon Admin Mod
    Posts: 5,362

    Sorry @dave1707, I'll log an issue on the tracker to add these.

  • Posts: 1,709

    Hi All,

    Just a quick update on what I've found in my code so far. Most of the problems have been related to math.mod() or math.random(). An example is in LightDye's thread and JMV38's Loading wheel code here:

    JMV38

    where I changed the code:


    self.light = math.mod(self.light + self.shift, 256)

    to


    self.light, temp = math.modf(self.light + self.shift, 256)

    Which managed to resolve the problem.

    By the way - I've seen several references to 'the documents' in this thread - which documents are they referring to?

    Thanks,

    Bri_G

  • dave1707dave1707 Mod
    Posts: 8,387

    @Bri_G The Docs I refer to are the build in documents (reference) or the link below.

    http://twolivesleft.com/Codea/Reference/
    
  • @dave1707 Hasn't it been moved to this link?

    http://codea.io/reference/
    

    I think it's more recent because the saveText() and readText() functions are documented in this one, but not the other one.

  • dave1707dave1707 Mod
    Posts: 8,387

    @Saturn031000 Thanks. I'll update my link to the new one.

  • json.encode fails if table contains functions.

    How do I get json.encode to let me default types it can't handle or add my own string and continue?

    I'm trying to use json for documenting abstract syntax tables generated by the Minifier parser instead of writing my own.

  • toffertoffer Mod
    Posts: 151

    @CodingOnNapkins - have a look at the dkjson doc : http://dkolf.de/src/dkjson-lua.fsl/wiki?name=Documentation. You can pass a function to catch exeptions.

    function ex (reason, value, stat, msg)
            return tostring...
    end
    print(json.encode(data, { exception = ex }))
    
  • color on document name offset when search icon tapped

    also the error bar

  • SimeonSimeon Admin Mod
    Posts: 5,362

    @CodingOnNapkins can you show me a screenshot of what you're referring to?

  • Posts: 835

    Small bug in the dependency selection, when the keyboard is up & you press the '+' and minimize the keyboard, the selector changes from the black theme, to a white colour

  • Jmv38Jmv38 Mod
    Posts: 3,295

    this kills my. codea. It used to work fine. Is it a bug in my version or is it the normal behavior? Thanks.


    --# Main -- testsss -- Use this function to perform your initial setup function setup() print("Hello World!") end -- this is a diagonal grid to visualize transparency function grid() local w = 20 local img = image(w,w) setContext(img) noSmooth() background(0) strokeWidth(0.5) stroke(128) for i=1,w/2 do line(0,i*2,i*2,0) line(i*2, w, w, i*2) end setContext() return img end -- a background image back = grid()
  • SimeonSimeon Admin Mod
    Posts: 5,362

    @Jmv38 that shouldn't kill Codea — that's a bug. I'll try to see if I can get render commands working in the global scope, I'm unsure if I will be able to do this.

  • edited March 2015 Posts: 1,709

    Hi All,

    Not sure if this is a feature of previous versions but - I have a problem with printing text out. I was downloading one of Ignatz's 3D model files and wanted to print it out to check it was there. It resulted in killing Codea. I tried again with a short part of the text printed and this was fine. Is there a limit on the print output buffer and is it protected? See code below.


    -- DownGist -- Downloading data function setup() -- Request some data http.request( 'https://gist.github.com/dermotbalson/7884446/raw/a9766e3e63a7e83ffcb73a3ae68e5beba4d0be96/gistfile1.txt', didGetData, didNotGetData ) end -- Our callback function function didGetData( data, status, headers ) strEnd = string.len(data) print("Downloading ") print(status) piece = string.sub(data,0,199) print("String length: "..strEnd) print(piece) -- print(data) end -- Our failure function function didNotGetData( error ) print( "Failed to get data. Error:" ) print( error ) end

    Remove the comment from the second print statement to see the effect. My iOS is 8.22 on an iPad 2.

    Bri_G

    note - edited print(status) line - no effect on program.

  • edited March 2015 Posts: 1,709

    Hi All,

    Question for anyone who knows - related to problem above. Is the Output window an image? The reason I ask is that if you increase the string length from 199 to 199248 (don't ask about the number) and you scroll down to the bottom (wait for the printing to finish) - then scroll the window up by touch - I see a black window with white text against a dark grey window. The movement of the text to me suggests that it is an image - probably saved to preserve processor time as against re-printing the window. If that's the case how is the memory management of the graphics done and can the size of the image get out of hand.

    Anticipating a reply - I think this window should be a real text based window and output control should be done with upward and downward scrolling buttons so that the output is limited to output window size. Also - it would be useful if we could have a 'clear' command to enable window clearing and then printing from the draw() function to avoid the inevitable scrolling when we really need overwriting.

    Then again I could be barking up the wrong tree.

    Bri_G

    image

  • @Bri_G - Not sure what you mean, but it made me find this. When you run this code, after some time the background turns black and Codea freezes. You can't exit or restart or scroll or anything.

    function setup()
        str=""
        for i=1, 199248 do
            str=str.."a"
        end
        print(str)
    end
    
    function draw()
        background(255, 255, 255, 255)
        strokeWidth(5)
    end
    
  • Posts: 1,709

    @Saturn031000 - thanks for confirmation that a long string can freeze the system. If you keep stroking the Output window upwards you will probably eventually see the effect I've mentioned when it displays the last line of the print output.

    I've also noted colour changes as you stroke the window - not every time flipping between a black background and the grey.

    Thanks,

    Bri_G

Sign In or Register to comment.