Simulator can hang without error message when non-existent variable referenced

,

This is on Mac (Apple Silicon). Sometimes† upon Build and Run (I'm using Nova if it matters) a line like this...

if  badVariableName then

will cause the Simulator to beachball, requiring a Force Quit. Nova's "Stop" button is grayed out, and the Run button is non-functional if you try it again. This doesn't happen on app launch, but rather when the line in question is executed.

No error message or console output appears, making it tough sometimes to track down which script has the problem.

† "Sometimes" means that if a line causes the issue, it will always do so... but there are also cases where a similar issue doesn't happen (the "if" simply evaluates to false) and I haven't spotted the pattern.

It happens about once a week to me, because it can result from a simple typo (or copy-paste-o). Or if I rename/remove a variable and forget that a second script also references it.

I hate to mention it since I've been trying to make a simple reproduction case and have failed to. But for what it's worth, I saved a copy of my messy project-in-progress that exhibits the issue on a certain a line. If anyone at Panic wants to wade into that swamp, I can provide it! I have marked the specific line.

(This definitely happened in both SDK 1.11 and 1.12. Not sure if it did before that.)

When this happens, does the same .pdx hang the simulator when you run it outside of Nova? (I'm trying to determine if the problem is related to the debugger.)

But yes, that messy project would help. Feel free to PM it to me.

Good question! Not exactly...

The PDX by itself does beachball on that line, rather than just evaluating to false, but after a few seconds it halts the Playdate game (no need to Force Quit) and shows some red feedback in the console:

CoreLibs/timer.lua:44: stack overflow
stack traceback:
	CoreLibs/timer.lua:44: in metamethod 'newindex'
	CoreLibs/timer.lua:84: in field 'new'
	main.lua:693: in function 'antiBurnInCheck'
	main.lua:808: in function 'clockSetup'
	phi.lua:42: in function 'phiInit'
	phi.lua:49: in field 'f'
	main.lua:982: in function 'renderClock'
	main.lua:824: in function 'startClock'
	main.lua:814: in function 'clockSetup'
	phi.lua:42: in function 'phiInit'
	...	(skipping 714235 levels)
	main.lua:982: in function 'renderClock'
	main.lua:824: in function 'startClock'
	main.lua:814: in function 'clockSetup'
	phi.lua:42: in function 'phiInit'
	phi.lua:49: in field 'f'
	main.lua:982: in function 'renderClock'
	main.lua:824: in function 'startClock'
	main.lua:814: in function 'clockSetup'
	phi.lua:42: in function 'phiInit'
	main.lua:775: in function 'screenChange'
	details.lua:177: in function <details.lua:150>

I'm guessing that clarifies the situation... And it tells me which script to look at, which is handy feedback to know I can get to next time.

(Also, I made an error above: Stop button in Nova is not ghosted. It can be clicked—it just doesn't bring the Simulator back to life. Then it's ghosted.)

Nice, glad to hear that helped.

Yeah, I guess we need to do a better job detecting/recovering from this situation. Thanks for the report!

1 Like

I cannot imagine the challenge of making an entire system from scratch, releasing it to developers, and then chasing down endless corner cases! But you guys have my thanks for taking it on!