I have a huge image as background and I move by panning across the world. However, at some point I get an exception like:
TypeError: Failed to execute ‘drawImage’ on ‘CanvasRenderingContext2D’: The provided value is not of type ‘(CSSImageValue or HTMLImageElement or SVGImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap or OffscreenCanvas)’
at Phaser.Sprite.PIXI.Sprite._renderCanvas (phaser.js:15712)
at Phaser.World.PIXI.DisplayObjectContainer._renderCanvas (phaser.js:15137)
at Phaser.Stage.PIXI.DisplayObjectContainer._renderCanvas (phaser.js:15137)
at PIXI.CanvasRenderer.renderDisplayObject (phaser.js:20531)
at PIXI.CanvasRenderer.render (phaser.js:20463)
at Phaser.Game.updateRender (phaser.js:36393)
at Phaser.Game.update (phaser.js:36314)
at Phaser.RequestAnimationFrame.updateRAF (phaser.js:61985)
at _onLoop (phaser.js:61968)
I changed the lines with try-catch to see which sprites are affected. There are multiple sprites… the funny thing: It paints everything fine when I start the state. Then I pan… and pan… and pan… sometimes, at the first pan this error occurs, sometimes after 2 minnutes panning around as if you’ve nothing else to do.
The previous state background is showing and then, after some seconds, it works again (because I catch the error, otherwise the whole game breaks).
Why would the type of a loaded sprite change? That makes no sense… especially because it’s drawn when I start the state and I can be drawn even after the exception is thrown.
I’m running out of ideas. Can someone help?