Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Codea 3.1 (208)

2»

Comments

  • edited March 23 Posts: 1,708

    @Simeon - before describing what happened here my apologies, saw this and couldn’t resist running it (yeah I’m weird):

    @dave1707 reported a crash of Codea (in October last year) with the following code -:


    function setup() xx="qwertyuiop" end function draw() background(0) xx=xx..xx end function temp() print("temp") end

    I ran it and lo’ and behold - it crashed!!! No surprise. But, the project printed an error “not enough memory” (9 instances) which looked like you might have resolved it - one up for 2LL. But it didn’t, it totally hung up Codea. Closing Codea and re-running hung up again or crashed. The only way I could get out of this was to switch off my iPad and reboot. Is this still expected?

    Posted here instead of editing errors thread as not known if this is an issue re-introduced in this beta.

  • dave1707dave1707 Mod
    edited March 23 Posts: 8,387

    @Bri_G @Simeon I saw that message a couple of days ago when I tried to crash Codea on purpose. I ran the below code which gave that message but didn’t cause and problems. When I got the message I could exit back to the editor and make changes.

    PS. I ran the code that Bri_G shows above, but I don’t hang or crash. I can exit back to the editor.

    displayMode(STANDARD)
    
    function setup()
        str="qwert"
        for z=1,10000 do
            str=str..str
        end    
    end
    
  • Posts: 1,708

    @dave1707 - after your message ran the code again and it came back with the same message with 20 repeats. It did re-run again coming back with 2 repeats ran it again 2 repeats again ran it again and it locked out Codea. Reset Codea ran again came up with message that Codea had crashed. Looks like there is some carryover from each error building up until Codea crashed.

  • dave1707dave1707 Mod
    Posts: 8,387

    @Bri_G I ran my code 30 times and Codea never locked up.

  • Posts: 1,708

    @dave1707 - used TestFlight to re-instal and ran without problem. Must have been some corruption. Thanks.

  • dave1707dave1707 Mod
    Posts: 8,387

    @Simeon Not a problem, just curious about this. If I run this code, it displays 13956 lines of the alphabet. If I increase the count by 1 to 13957, it doesn’t print the alphabet. If I cut the string in half so 2 print on a single line then I can increase the count to 27912. So it appears that print has a limit of what it can print in one group, that being 13956.

    function setup()
        tab={}
        str="abcdefghijklmnopqrstuvwxyz"
        for z=1,13956 do
            table.insert(tab,str)
        end
        print(table.concat(tab," "))
        print(#tab)
    end
    
  • Posts: 1,708
    @dave1707 - did you at any time get the 'not enough memory' message? ie is there a self imposed limit?
  • dave1707dave1707 Mod
    Posts: 8,387

    @Bri_G If you’re referring to the above code, no, I didn’t get the memory message. It uses less than 363,000 bytes of memory for the info in the table. Maybe I’ll try to get a byte count that causes the memory message.

  • Posts: 1,708
    @dave1707 - a byte count could be useful. That's an odd number for the info in the table.
  • dave1707dave1707 Mod
    edited March 23 Posts: 8,387

    @Bri_G
    I think the memory message might be different depending on how much memory the device has.

    For the number of bytes in the table, I don’t think that matters. If I cut the size of the letters in str, the limit is still 13,956. If I cut it down small enough so it prints 2 occupancies per line, then I can double the line count. So it’s the number of lines and not the number of bytes.

  • dave1707dave1707 Mod
    edited March 23 Posts: 8,387

    @Bri_G Heres some code to run that gives the memory error and byte count. I get to a count of 25 with 905969664 bytes before the memory error. I’m on a 64gb iPad Air 3. So the max memory is somewhere above that value and less than twice that value.

    PS. I tried running this on my 12.9” iPad Pro 1 128 GB and it gets to the count of 25 and then crashes Codea. Both are on version 3.1(208). I don’t get the memory message.

    displayMode(STANDARD)
    
    function setup()
        str="aaaaaaaaaaaaaaaaaaaaaaaaaaa"
        for z=1,1000 do
            str=str..str
            print(z.."  "..#str)
        end
    end
    
  • edited March 23 Posts: 1,708

    @dave1707 - I get exactly the same as you for your last post, crashes. My pad is iPad Pro 9.7” 128 GB. Printed up to 24. On you previous post whatever you put into the upper value for z in the for statement is printed out, no crash but no text string visible in the print window. This must be because of the way Codea handles strings. That has always been a slow output - why? Is there some optimisation of code, which outputs to the screen, but no optimisation (Lua library) for print output to the output window.

    p.s. are both your iPads on iOS 13.3.1 ?

  • dave1707dave1707 Mod
    Posts: 8,387

    @Bri_G Both on iOS 13.3.1 . Not sure why my iPad Air 3 doesn’t crash but my iPad Pro 1 does when I run the code for memory error.

  • dave1707dave1707 Mod
    Posts: 8,387

    @Simeon I posted this code farther up, but I just found something strange about it. I thought that if there was too much to print that it didn’t print anything. But what I found out was it just prints blanks. If you change the for loop count to 13956, it prints the alphabet 13956 times. If it’s 13957 then it prints blanks. If you run this, you’ll see that it prints the table size of 13957 and the string end. If you scroll the print window all the way to the beginning, you see the string start. It’s all blank in between. I don’t think this is by design because why would you print just blank lines instead of not printing anything at all.

    function setup()
        print("start")
        tab={}
        str="abcdefghijklmnopqrstuvwxyz"
        for z=1,13957 do
            table.insert(tab,str)
        end
        print(table.concat(tab," "))
        print(#tab)
        print("end")
    end
    
  • SimeonSimeon Admin Mod
    Posts: 5,362

    @dave1707 hmm that seems like it could be a UI layout issue triggered by printing. I think I need to scrap the whole output window and replace it with something better

  • dave1707dave1707 Mod
    Posts: 8,387

    @Simeon I’m not sure how this happened. I was editing some code and a black circle appeared and I couldn’t get rid of it. Also, the code kept scrolling to the bottom. I would scroll the code to the top and after I reached the top, it slowly started scrolling back to the bottom. It did that several times. I exited the editor and went back in and everything was ok.

  • SimeonSimeon Admin Mod
    Posts: 5,362

    @dave1707 wow, that is really strange. It almost looks the same size and shape as the magnifying loupe

  • dave1707dave1707 Mod
    Posts: 8,387

    @Simeon I did a screen save of the magnifying loupe over the same area of the code. I was able to overlay the one image over the other and they both look like they’re the exact same size.

  • SimeonSimeon Admin Mod
    Posts: 5,362

    @dave1707 the next version of Codea gets rid of the magnifying loupe (replacing it with the Apple standard text controls since iOS 13). So this bug may be resolved as a result of that

  • edited April 9 Posts: 1,708

    @Simeon - run the code below then change the colour for the image but don’t enter from the colour wheel - instead, with the colour wheel open tap the run button.


    function setup() -- img = image(600,600) setContext(img) spriteMode(CORNER) fill(132, 236, 67) rect(0,0,600,600) setContext() end function draw() -- This sets a dark background color background(40, 40, 50) sprite(img,WIDTH/2,HEIGHT/2) end
  • dave1707dave1707 Mod
    Posts: 8,387

    @Simeon @Bri_G Are you referring to Codea crashing if you run the code with the color wheel open. The below code crashes if run with the color wheel open.

    function setup()
        fill(132, 0, 67)
    end
    
  • edited April 9 Posts: 1,708

    @dave1707 - yup, it also does it wth the rectMode() rect() on mine. Looks like leaving the colour routine unclosed triggers the bomb. Are all the routines provided with active/inactive flags which are parsed before the run command is permitted to fly?

    Edit: From your observation looks like it’s just the colour wheel. Also this was easy to miss as a slight offset on the run button closes the colour wheel.

  • dave1707dave1707 Mod
    Posts: 8,387

    @Simeon I think this was reported before, but I can’t find where, so I’ll show it again. This shows the UFO and the KEY. But it you slide the parameter to false, it shows 2 UFO’s. It should always show the UFO and the KEY.

    displayMode(STANDARD)
    
    function setup()
        parameter.boolean("show",true)
        pic=readImage(asset.builtin.Space_Art.UFO)
    end
    
    function draw()
        background(0)
    
        if show then
            sprite(asset.builtin.Space_Art.UFO,WIDTH/2,HEIGHT/2+100)
        else
            sprite(pic,WIDTH/2,HEIGHT/2+100)
        end
    
        sprite(asset.builtin.Planet_Cute.Key,WIDTH/2,HEIGHT/2)
    
    end
    
    
    
    
  • Posts: 528

    yikes!

    -- davebug
    displayMode(STANDARD)
    
    function setup()
        pic=readImage(asset.builtin.Space_Art.UFO)
    end
    
    function draw()
        background(0)
    
        sprite(pic,WIDTH/2,HEIGHT/2)   
        sprite(asset.builtin.Planet_Cute.Key,WIDTH/2,HEIGHT/2-100)
    
    end
    
  • dave1707dave1707 Mod
    Posts: 8,387

    @piinthesky I don’t remember who posted this, I think @Bri_G did. I’m not sure how long ago it was but I think we had a Codea release since then. Maybe, maybe not. Time seems to be standing still.

  • edited April 11 Posts: 1,708

    @Simeon - couple of things I have noticed about the new asset system:

    Firstly, I have cut and pasted a long asset link address over a selected variable in a definition, in doing so it lost the asset part of the link and started with .documents

    Secondly, I think the asset list has an issue at times, not sure if it relates to reserved words but I have a Dropbox folder named planeTXT which it sees as planetxt - the problem is it can not see the real name (case sensitive) and so can not see the enclosed files. I get round it by typing in planeTXT at the .

    Edit: Another thing I noticed was I selected an asset path which was at the end of a function call with other parameters to paste a new path. When I did there was two asset parts to the new address - like 'assetasset.documents ..etc'.

  • edited April 12 Posts: 1,708

    @Simeon - couple of things possible issue.

    First simple thing I have a lot of projects on my Codea project screen. A lot sorted into collections. I recently scrolled down in portrait mode to open a collection looking for a project and found it. Thinking of the project I wanted to run I turned the screen to landscape mode and the project icons present were well away from the ones I wanted. So I had to rescroll to find my project again. This suggests the project screen is One big image - is that so? If so it could possibly take up a lot of memory. Are all apps allocated a finite memory slot or is it extendable as required?

    Secondly, I’m struggling with the asset path system in the beta. For a single instance it’s fine but with the old mode of addressing I could use a path and concatenation with a table for the final file name. I can’t seem to get the current system to use a table of files. If it is possible could you describe the syntax needed.

  • SimeonSimeon Admin Mod
    Posts: 5,362

    @Bri_G it's not one big image, what's happening is that the scroll offset is maintained from landscape to portrait, but that doesn't make any sense for a long list. So for example if you are 3000 pts down in portrait then rotate to landscape, you're going to be 3000 pts down in landscape, which is not going to be showing the same set of projects.

    What I need to do is check which project was at the top of your list and compute the position of that project in the other orientation / view size, then scroll to that

    Can you be more specific on the issue you have with the asset paths? Could you post some code where it's not working for you?

  • dave1707dave1707 Mod
    Posts: 8,387

    @Bri_G Are you looking for something like this where you put a variable name in the [ ]. I use the below code to get different files. You can use one [ ] or 2 like I have below.

    a=asset.builtin[name1][name2]
    
  • edited April 12 Posts: 1,708
    @dave1707 @Simeon - thanks for the replies I have dependencies which contain lists of assets in tables, usually setting a path up like -

    ~~~

    path = "Dropbox:folder/"
    path = asset.documents.Dropbox

    ~~~

    The latter is what I have tried recently, then examples of use are:

    ~~~

    rabbit = craft.model(path..model[num])

    ~~~


    Where model is a table of filename strings with object names in. The old system works well. The new one doesn't seem to work. Using the new asset system errors keep getting fired up. Using a single complete asset path, no table, models load fine - note no file type in asset path. That's the same with the old system, no file type. I managed to get one file to load by appending .obj to the file string in the table but all others failed.

    The other files all use the underscore character - a feature of Wavefront files. They are OK with the single complete asset path but not with the table concatenation method. Could these characters be the cause?

    @dave1707 - I'll give your format a try.

    p.s. - please ignore code formatting above, added this on my Android phone and seems format code on the forum differently.
  • SimeonSimeon Admin Mod
    edited April 12 Posts: 5,362

    @Bri_G you need the full filename, including extension, to use the syntax you describe

    If you want to get all models in your Dropbox (or any) folder, you can do something like

    1:

    models = {}
    
    for _,k in pairs(asset.documents.Dropbox.all) do
        if k.type == MODELS then
            table.insert(models, k)
        end
    end
    

    Later on to load a model...

    rabbit = craft.model(models[num])
    

    2:

    Or if you wanted static analysis to ensure files exist, you could do something like:

    models = {
        asset.documents.Dropbox.rabbit,
        asset.documents.Dropbox.anotherModel,
        asset.documents.Dropbox.andSoOn
    }
    
    rabbit = craft.model(models[1])
    

    Then Codea will let you know in the editor if any of those files doesn't exist before you run your code

    3:

    You shouldn't really need the .. concatenation operator unless you want to create a file that doesn't exist yet. If you want to load an existing file it's likely you already have the asset key stored for it, so you can just load that. But if you really want to use the .. syntax you can do it like this (though I'd recommend the first way)

    models = {}
    
    for _,k in pairs(asset.documents.Dropbox.all) do
        if k.type == MODELS then
            -- Here we insert the file name instead of the key
            table.insert(models, k.name)
        end
    end
    

    Later on to load a model...

    rabbit = craft.model(asset.documents.Dropbox .. models[num])
    

    (I don't recommend that way, just store the keys instead and load them directly)

  • Posts: 1,708

    @Simeon - back on my Mac and sensible editing of web code again.

    Thanks for the reply - and thanks for outlining the options that we have for using the new asset path system. I will try them all out - should make my old systeem well and truly redundant.

    Thanks again.

  • dave1707dave1707 Mod
    Posts: 8,387

    @Simeon I just ran across something that worked before the asset change, but doesn’t work now. At least I can’t get it to work. I have a program where I read an image from the Dropbox folder and display it. If the image doesn’t exist in Dropbox then I do an http request to get it and put it there. What happens now is if the image isn’t in the Dropbox folder, it gives an error and stops the program so it isn’t able to do the http request.

  • Posts: 1,708

    @dave1707 - I have tried with a number of my models with the code from you and @Simeon but have run into problems. I think the problems are a feature of model integrity.Many of the models I use loaded with the old system but not the new. To check I loaded a number of non-textured models from the following website:

    A 3D Object Format

    They all loaded successfully. I have built a loader using the method I found to load reproducibly below. I have a few issues with this - firstly the code needs to destroy one model before loading a second (otherwise they get superimposed) - my code doesn't work - can you see my error?

    Secondly, have you seen a reference within the forum for examining a model and reducing/increasing the size to comfortably fit in the screen on the centre of the iPad?


    function setup() -- ship = 1 models = {} count = 0 path = asset.documents.Dropbox.ModelWorkers for _,k in pairs(path.all) do if k.type == MODELS then table.insert(models, k) count = count+1 end end print(count) print(#models) for lp = 1,#models do print(models[lp].name) end parameter.intesger("modl",1,#models) parameter.action("Load", function() -- e.entity:destroy() newModel(modl) end) scene = craft.scene() scene.camera.eulerAngles=vec3(ex,ey,ez) scene.sun.rotation = quat.eulerAngles(45,0,45) scene.ambientColor = color(90,90,90) skyMaterial = scene.sky.material skyMaterial.horizon = color(0, 203, 255, 255) v=scene.camera:add(OrbitViewer, vec3(0,0,0), 10, 0, 100) e=scene:entity() pos = {x=0,y=0,z=0} rot = {x=0,y=0,z=0} tween(24,rot, {x=-0,y=360,z=0}, {easing = tween.easing.linear,loop = tween.loop.forever}) e.rotation = quat.eulerAngles(-90,0,0) end function update(dt) scene:update(dt) e.rotation=quat.eulerAngles(rot.x,rot.y,rot.z) e.position=vec3(pos.x,pos.y,pos.z) end function draw() update(DeltaTime) scene:draw() end function newModel(num) -- delets old model and loads new if e.entity then e.entity:destroy() newModel(num) else e = scene:entity() e.model = craft.model(path .. models[num].name) e.position = vec3(0,0,0) e.scale = vec3(1,1,1)/20 end end

    I am exploring the other options for loading these models to get used to the syntax and check they work OK. All my models were held on my Dropbox account in the folder called ModelWorkers as can be seen in the above code.

    I tested the models I downloaded in the Mac default 3D viewer (think it's in Xcode) many of my other models don't seem to load properly in that viewer - do you know of any viewer that is 'more tolerant' to model format?

    The models I used were cessna, trumpet, violin case, airboat, shuttle and minicooper.

    I do have a couple of textured models that I have managed to load with this code still trying to figure out what's wrong with the rest!!!!

  • SimeonSimeon Admin Mod
    Posts: 5,362

    @Bri_G your line in newModel function reading:

    e.model = craft.model(path .. models[num].name)

    Could be changed to:

    e.model = craft.model(models[num])

    Keeping path is unnecessary as this is part of the asset key you are storing in the models table.

    Are you saying that when changing the line to use the old-style asset string:

    e.model = craft.model("Dropbox:ModelWorkers/ModelName")

    It loads differently? Are you able to specify which models this happens with?

  • Posts: 1,708

    @Simeon - thanks for the response on that, should have realised that as I have printed out the list paths when checking the table contents.

    I'll see if I can find an example of a model that has issues with the addressing mode to post to you. Thanks.

  • Posts: 528

    @Bri_G to avoid the models overlapping you would need to give each one a different position. You can modify the scale property to set the size of a model.

  • dave1707dave1707 Mod
    Posts: 8,387

    @Bri_G Make this change to your above code.

    function newModel(num)
        -- delets old model and loads new
        if e then
            e:destroy()
        end
        e = scene:entity()
        e.model = craft.model(path .. models[num].name)
        e.position = vec3(0,0,0)
        e.scale = vec3(1,1,1)/20
    end
    
Sign In or Register to comment.