Howdy, Stranger!

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

Grid causes crash

edited August 20 in Bugs Posts: 1,292

Attached is my World Grid which is adapted from the grid used in the voxel editor project by @John.

It’s pretty elegant code I think, small and straightforward.

I put in a parameter control that changes the render distance of the grid—it’s the second one.

If I turn it on and off three times or so, Codea crashes.

Can anyone see what’s happening there (again, most of it is pretty small and straightforward code, mainly because it’s not mine :) )?

Tagged:

Comments

  • edited August 20 Posts: 172

    basically every time you turn this off and on, the craft scene engine has to regenerate the mipmaps-

    if not self.shortenedRenderDistance then
            craft.texture(self.img):generateMipmaps()   --remove fog effect
            self.img.premultipled=true
        end
    
    

    this means all these mipmaps steal memory and are never cleaned up, i’m not sure if there is a direct way to destroy them but if you add the line collectgarbage() at the end of the draw function it will fix the crash

    personally i use collectgarbage() at the end of my draw function in all projects i’ve worked on as i don’t see it effecting performance at all and it’s only beneficial to have cleanup every frame

  • Posts: 2,364

    @skar @UberGoober - tried adding the collectgarbage() in the draw function then flipped the visible/invisible parameter several times then the second parameter Codea crashed.

    I don’t think it’s something to do with the setting up parameters part of the class. I think they may need to be independent of the class and call the class with the entity id.

  • Posts: 172

    hmm it works to fix the crashing for me, maybe because i’m on the M1 chip

  • dave1707dave1707 Mod
    Posts: 9,441

    For me, it crashes every time I slide the parameter “grid fades with distance”.

  • Posts: 1,292

    collectgarbage() is working for me so far.

  • dave1707dave1707 Mod
    Posts: 9,441

    If I put collectgarbage() in draw, it still crashes every time I slide the “grid fades with distance” to off.

  • edited August 21 Posts: 1,292
    @dave1707 please let me know if you ever find a solution.

    I’d try to help if I could, but I can’t see what I could really do, because it’s not happening for me anymore. If there’s a way I can help I’ll be happy to.
  • edited August 21 Posts: 2,364
    All, can you post what your iOS and kit id's are. I get exactly the same as @dave1707. Although I have played around with it a bit, but I don't think the changes I made are responsible.

    @skar - in there fast, how you finding the M1?
  • Posts: 172

    @Bri_G it’s awesome, i got the 11” and it flys through everything

Sign In or Register to comment.