Resizing the Console can crash the Playdate Simulator

This happens on macOS 12.3.1, with SDK 1.9.3. It appears all you need to do is call both print and playdate.sound.micinput.stopRecording().

See it in action here:
ezgif-5-31b0ed579a

Repro steps:

  1. Open the enclosed project (or copy the pasted code below)
  2. Run it in the simulator
  3. Wait a moment
  4. Try to resize the console window.

The code I used to crash it is this:

local snd <const> = playdate.sound

local updateCall = 0
local recording = snd.sample.new(5.0, snd.kFormat16bitMono)
local player = snd.sampleplayer.new(recording)

function playdate.update()
    -- updateCall is used to make sure these methods are called in a specific
    -- order, to get the app in a specific state.
    updateCall += 1

    if updateCall == 1 then
        -- `print` has to be called. Commenting this out avoids the crash
        print("Launched")
    elseif updateCall == 5 then
        -- Strictly speaking, this call isn't needed. It will crash whether or
        -- not this method is called.
        snd.micinput.recordToSample(recording, function () end)
    elseif updateCall == 100 then
        -- `stopRecording` has to be called. Commenting this out avoids the crash.
        snd.micinput.stopRecording()
    end
end

test-crash-playdate-on-console-resize.zip (50.5 KB)

Very interesting. Thanks for the report, and for spending the time to isolate the problem. We'll look into it ASAP.

Okay, got it: I was calling the underlying stopRecording() function twice on accident, which means the second call was trying to remove a nil node from the audio graph, which caused an exception. That caused an unexpected return from the update cycle which left the text transaction open in the console, which caused the resize to throw an exception. Crazy!

Thanks for catching this! It's a very weird bug :flushed:

3 Likes

Wow. That sounds like quite the Rube Gold-bug. Glad you were able to track it down so quickly. :playdate_happy:

It was easy, you did all the hard work tracking it down! Thanks for the great bug report :smiley:

2 Likes

Hey; I'm still seeing this behavior on

  • SDK 1.11.0
  • Nova 9.3
  • macOS 12.3.1

Is that expected?

ugh. nope, looks like it's still in the queue. :frowning: We're stretched a little thin right now. Hopefully we can get this through soon

Ok, no worries. Glad it's still on your radar. I can only imagine how busy y'all are right now. :playdate_cry_laugh:

1 Like

For anyone watching this: It's fixed as of SDK 1.12.0! :playdate_heart_eyes:

2 Likes