Simulator crashes when calling playdate.wait() while a sound sequence is playing

Bug discovered with Lua code using the Simulator on a Mac.

If a playdate.wait() is called while a playdate.sound.sequence is playing, it will not only cause the code to break, but it also causes the simulator to crash.

You can reproduce this easily using the DrumMachine example from the SDK and arbitrarily adding playdate.wait into the update loop somewhere like so:

function playdate.update()
	-- The only thing we have to do here is update the display when the play step changes
	local step = sequence:getCurrentStep()

	if step ~= laststep then
		grid:draw(0,0)
		local x = TEXT_WIDTH + step * ROW_HEIGHT - ROW_HEIGHT/2
		gfx.fillRect(x-1, 0, 2, 240)
	end
	--Adding code to create the crash here:
	if playdate.buttonJustPressed("b") then playdate.wait(50) end
end

Tips on how to write a bug report:

  1. Have a clear title.
  2. If relevant, tell us what platform you're using the SDK on (Mac, Windows, Linux)
  3. Explain what the expected result was and what happened instead.
  4. Provide details on when and where this bug happens. Videos and images of the issue can be helpful.
  5. Instructions on how to reproduce the issue.

Yup, that is a reproducible crash. Filed, thanks!

1 Like