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…
@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.
@MalikWilburn @dave1707 good find, will fix!
This code seems OK for me, does it crash for you?
function setup()
print("Hello World!")
parameter.action("Close Runtime", function()
close()
end)
end
@Simeon The above code crashes all the time on my iPad Air with ver 118 and my iPad Pro ver 120.
@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.
@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
@Simeon - same on iPad Pro.
@simeon the code crashes for me on ipad pro
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.
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…
@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.
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
@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
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.
@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
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.
@Bastis I guess @Simeon will have to figure it out.
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