panels icon indicating copy to clipboard operation
panels copied to clipboard

imageTable layers crash when using `renderLayerInPanel`

Open cadin opened this issue 1 year ago • 0 comments

If an imageTable layer is rendered in a custom function with renderLayerInPanel Panels will crash unless you specify a startDelay for the layer.

cntrlPct is nil in this case which causes the crash trying to do the comparison at line 158 in Layers.lua.

elseif layer.animationLoop then
	if layer.visible then
		if layer.trigger then
			if pdButtonJustPressed(layer.trigger) then
				layer.animationLoop.paused = false
			end
		elseif layer.startDelay then
			if layer.startDelayTriggered == nil then
				playdate.timer.performAfterDelay(layer.startDelay, function()
					if layer.animationLoop then layer.animationLoop.paused = false end
				end)
				layer.startDelayTriggered = true
			end
		elseif cntrlPct >= layer.scrollTrigger then -- <-- CRASH HERE
			layer.animationLoop.paused = false
		end
		layer.animationLoop:draw(xPos, yPos)
	end
end

An easy workaround is to set a startDelay on the imageTable layer. It can be set to 0 if no delay is desired.

cadin avatar Jul 07 '24 22:07 cadin