playdate.display.setOffset crashes Simulator

,

Windows, SDK 3.0.3 (also occurs on 3.0.2)

I was wandering down a dungeon hallway in my mixed C and Lua project, testing how much getting impaled by spikes and roasted by fireballs hurts (as one does) when I got a nasty crash:

Hmm (says I), that stack trace is not very informative. In fact, it looks like my C chunk wasn’t involved at all.

After much binary-search-code-outcommenting, I arrived at the culprit - up in the Lua layer, my ‘shake screen’ effect when zapped by sharp/hot objects was bringing everything crashing down.

So I whomped up a quick and tiny Lua project example (attached: ShakeIt.zip (463.1 KB)) that pretty reliably crashes the Simulator:

The Lua code is pretty simple:

local gfx = playdate.graphics

local shakePending = false
local shakeX = 0
local shakeY = 0
local shakeCount = 0
local shakeTrigger = 6

function shakeCheck()
if shakePending == false then return end

shakeX = math.random(-2,2)
shakeY = math.random(-2,2)

shakeCount = shakeCount + 1
if shakeCount > shakeTrigger then
    shakeCount = 0
    shakeX = 0
    shakeY = 0
    shakePending = false
end

playdate.display.setOffset(shakeX, shakeY)

end

gfx.setColor(gfx.kColorWhite)
gfx.setImageDrawMode(gfx.kDrawModeCopy)

function playdate.update()
gfx.fillRect(0, 0, 400, 240)
playdate.drawFPS(0,0)

gfx.drawText("Hold 'A' to Shake it, and crash the Simulator!", 20, 20)

if playdate.buttonJustPressed(playdate.kButtonA) and (shakePending == false) then
  shakePending = true
end

shakeCheck()

end

It may be that I’m Doing Something Quite Wrong ™ in the above (in my actual code, later on I’m re-setting the offset back to 0,0), and that’s fair - but IMO whatever the wrongness is that shouldn’t crash the Simulator.

(it may take tapping the A button a couple of times to crash things, though for me it pretty reliably crashes on the first tap)

edit: this is relatively new behavior, as far as I know - things used to shake fine… I just haven’t wandered down that hallway in a few (?) weeks and now things crash pretty reliably.

edit2: I tried this on actual hardware (RevA/3.0.3), no crash (so, some good news to go with the bad).

Enjoy! :melting_face:

1 Like

oof. Looks like that one goes back to 3.0.0, was the result of some optimizations. I'll get a fix in and post a build here so you don't have to wait for the next update.

3 Likes

Sorry for the delay! I had to clear a completely different issue before CI would give me a build. Let's try just the exe first, see if that works:

PlaydateSimulator.exe.zip (1.2 MB)

I'm not familiar with the windows sim but I'm assuming all the dlls are the same so there's no need to re-upload those. Let me know if you have any trouble with this!

That seems to have fixed it… looking good!

Thanks! :slight_smile:

utt2_shake_bug_fixed

1 Like

Dave,

I just updated to SDK 3.0.5, and the setOffset crash is still happening (meaning, your fix didn’t make it into the repository trunk, or however you say something like that for whatever configuration management system you’re using).

Just thought I’d give you a heads-up, this issue is still present in SDK 3.0.5. :slight_smile:

ah, dang. It's targeted for 3.1, which was going to be the next one out the door until some annoying bugs popped up and we had to get a couple of bugfix updates out. But I'm back to wrapping up 3.1 now and we'll get it out as soon as we can. Thanks for the update!

1 Like