Howdy, Stranger!

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

“Close Project” Crash

One of my projects crashes often (not all the time) when I use the close() function. Is there a general reason it crashes? It doesn’t seem to be a glitch on Codea’s part...

Comments

  • dave1707dave1707 Mod
    Posts: 8,464

    @MalikWilburn Nice Find. When I try programs with close() in it, they crash every time. @Simeon The close function crashes Codea in both versions 118 and 120.

  • SimeonSimeon Admin Mod
    Posts: 5,387

    @MalikWilburn @dave1707 good find, will fix!

  • SimeonSimeon Admin Mod
    Posts: 5,387

    This code seems OK for me, does it crash for you?

    function setup()
        print("Hello World!")
    
        parameter.action("Close Runtime", function()
            close()
        end)
    end
    
  • dave1707dave1707 Mod
    Posts: 8,464

    @Simeon The above code crashes all the time on my iPad Air with ver 118 and my iPad Pro ver 120.

  • dave1707dave1707 Mod
    edited December 2018 Posts: 8,464

    @Simeon A little more testing with the above code. If I run the code and I return to the editor using the icon in the lower left then run the program and press the Close Runtime button, it doesn’t crash. It seems to crash if close() is the first to exit the program.

    PS. A little more testing. The crash seems to occur after a fresh startup of Codea. If there’s a successful close, the program can be closed and restarted and closed() without a crash.

  • SimeonSimeon Admin Mod
    Posts: 5,387

    @dave1707 odd, I can't get that example to crash even on a clean load of Codea.

    Might try on other devices too

  • Similar on my iPad Air 2

  • Posts: 1,757

    @Simeon - same on iPad Pro.

  • @simeon the code crashes for me on ipad pro

  • SimeonSimeon Admin Mod
    Posts: 5,387

    Thanks everyone, the App Store version of Codea crashes for me too with the above code, but the beta version of 2.6.2 does not. So perhaps this is fixed.

    Might still look into what it was though.

  • edited April 18 Posts: 12

    I know this is an old thread, but the same thing started happening to me now with the latest version of Codea. Don't know if it's the same issue or something else. I can share the code, but it's somewhat lengthy. Just tell me if it would help find the problem.

    Edit: it seems to happen when I've used readLocalData in a Highscore situation. Might be something else there that's messing things up...

  • dave1707dave1707 Mod
    Posts: 8,464

    @Bastis I can’t get it to crash Codea. I’m doing a readLocalData and a close(). Can you copy your code and then keep commenting out chunks of code as you do the close() to crash Codea. Make sure you do the long press on the Run icon to get the Save and Run pop up. Otherwise, when Codea crashes, any changes you make won’t be saved. Maybe you’ll get it down to a small chunk you can post or maybe you’ll find a chunk of code that’s causing it.

  • Posts: 12

    I did some testning, and after removing more and more code to see what caused it. Eventually everything was gone pretty much. I found that the localData didn't have anything to do with it. I started a new project and after running it a few times it crashes too. The only thing it does is close() whenever I touch the screen and it takes between 2-10 attempts to get it to crash. I'm using Codea on an iPhone btw.

    -- Test3
    
    -- Use this function to perform your initial setup
    function setup()
        print("Hello World!")
    end
    
    -- This function gets called once every frame
    function draw()
        -- This sets a dark background color 
        background(40, 40, 50)
    
        -- This sets the line thickness
        strokeWidth(5)
    
        -- Do your drawing here
    
    end
    
    function touched(touch)
        close()
    end
    
    
  • dave1707dave1707 Mod
    Posts: 8,464

    @Bastis I loaded your code and I couldn’t get it to crash after 100 times. I’m on an iPad Air 3 with 64GB memory Codea version 3.1 (208). Try changing the touched function to this and try.

    function touched(touch)
        if touch.state==BEGAN then
            close()
        end
    end
    
  • Posts: 12
    No improvement. I'm on an iPhone 6 with IOS 12.4.5 and run Codea 3.1 (208). My phone isn't in the best shape and runs pretty slow at times.
  • dave1707dave1707 Mod
    Posts: 8,464

    @Bastis See if this does any better. Just have only this function, no setup(), no Draw(). I added a return statement. Don’t know if that will help any, just trying different things.

    function touched(t)
        if t.state==BEGAN then
            close()
            return
        end
    end
    
  • edited April 19 Posts: 12

    Good idea, crashed on the second attempt though.

    The programs never crash when I use the back button on the side panel (the one with parameters and print() output).

    Edit: Running a close()-command in the commands-field in the side panel doesn't crash it either.

  • dave1707dave1707 Mod
    Posts: 8,464

    @Bastis I guess @Simeon will have to figure it out.

  • Posts: 12

    Thanks for trying though Dave! Any way to gather a crash report to send to Simeon?

    It's wierd the first code crashes it, but the second one doesn't, even if I tap the screen.

    function setup()
        b=50
    end
    
    function draw()
        if b<1 then
            close()
        end
    
    end
    
    function touched(t)
        b=0
    end
    
    function setup()
        b=50
    end
    
    function draw()
        b=b-1
        if b<1 then
            close()
        end
    
    end
    
    function touched(t)
        print("test")
    end
    
  • dave1707dave1707 Mod
    Posts: 8,464

    @Bastis Try replacing close() with restart() and see if that does anything different. Not sure why you don’t get a pop up asking if you want to send crash information. Whenever I crash Codea, I get a pop up that asks, but I just ignore it.

  • SimeonSimeon Admin Mod
    Posts: 5,387

    @dave1707 the popup only happens in the beta version (please send though if you get a crash, I often go through and analyse the crashes that get submitted)

    @Bastis that is so weird, I don't get a crash in either case but I wonder if it's down to using the previous version of iOS. I'll look at the close() function but I'm not sure if there's much I can do to fix this

  • Posts: 12

    Thanks for the response! I'll try updating the iOS

  • SimeonSimeon Admin Mod
    Posts: 5,387

    @Bastis I think if you are on iPhone 6 you may be limited to iOS 12, which is a bit unfortunate

  • Posts: 12

    Ah, I updated to 12.4.6 from 12.4.5. That didn't do it. I also turned the phone off and on again (which should have been the First thing I tried actually) and that didn't fix it either.

  • SimeonSimeon Admin Mod
    edited April 22 Posts: 5,387

    @Bastis sorry about the bug and that I can't resolve this for you, does this work for you?

    function setup()
    
    end
    
    function draw()
    
    end
    
    function touched(t)
        if t.state == ENDED and t.tapCount == 1 then
            tween.delay(0.1, function() 
                close()
            end)
        end
    end
    
  • Posts: 12
    It did! In fact all that was needed was the ENDED state. Doesn't work with BEGAN though. Perhaps it gets called twice or something causing a crash?

    Thank you so much! The customer support for Codea is really top of the line!
Sign In or Register to comment.