Just "finished" a small game, but I've been seeing behavior throughout the entirety of the project related to "bad loadlen" errors being thrown over and over again, and I believe they have something to do with fileplayer. Something about garbage collection, CPU or memory retention.
Game will freeze up and then crash, most notably in roomFour() in the roomFourFinished conditional statement (I literally had to make this crash a feature because I couldn't resolve it. I have audio that plays saying "press A i'm going to crash soon press A" over and over until it crashes a few seconds later. Pressing A will move you to the next room).
This is with mp3s, but I've tried to resolve with wav ADPCM instead. Per the following post: Music, Sound, Animation & Image auditioning app - #21 by matt, I have also tried fileplayer:setStopOnUnderrun() and setting a buffer when initializing a new fileplayer, but both of those actually make the issue worse. This issue is unfathomably worse in simulator and can occur in a number of places, but really only occurs in roomFour after moving the shower curtain all the way over on hardware. In simulator, it can occur even right after the very first mp3 plays, which is right after cranking through the title screen lock frames.
I would love to resolve this behavior so I can fix my semi-finished project. Here's a snapshot of roomFour code, but I've attached the full .pdx as well:
function fade(fadeTime, --[[optional]]imageSource) local blackImage = gfx.image.new(imageSource or "Images/fade/black.png") blackImage:draw(0, 0) playdate.wait(fadeTime) end function roomFourSetUp() gfx.sprite.removeAll() gfx.clear() playdate.stopAccelerometer() roomFourFinished = false roomFourFrame = 0 playdate.graphics.setBackgroundColor(gfx.kColorClear) roomFourAnimation = gfx.imagetable.new("Images/roomFourAnimation.gif") roomFourAnimation:getImage(1):draw(0, 0) local textBoxImage = gfx.image.new("Images/textBox.png") textBoxSprite = gfx.sprite.new( textBoxImage ) endSound = playdate.sound.fileplayer.new("sound/pressA.mp3") crashSound = playdate.sound.fileplayer.new("sound/crash.mp3") end function roomFour() local roomFourtickCounter = playdate.getCrankTicks(4) -- every time a tick gets hit, add 1 to roomFourFrame if roomFourtickCounter == 1 and roomFourFrame < 30 then roomFourFrame = roomFourFrame + 1 roomFourAnimation:getImage(roomFourFrame):draw(0, 0) elseif roomFourtickCounter == -1 and roomFourFrame > 1 then roomFourFrame = roomFourFrame - 1 roomFourAnimation:getImage(roomFourFrame):draw(0, 0) end if roomFourFrame == 30 then roomFourFinished = true end if roomFourFinished then textBoxSprite:moveTo( textBoxX, textBoxY ) textBoxSprite:add() local text1img = gfx.image.new("Images/text/roomFourText.png") text1 = gfx.sprite.new(text1img) text1:moveTo(textX,textY) text1:add() endSound:play() crashSound:play() if playdate.buttonIsPressed(playdate.kButtonA) then endSound:pause() crashSound:pause() fade(4000, "Images/fade/room5TitleScreen.png") state = "roomFive" end end
Horizontal.pdx.zip (1.4 MB)