tileSprite out of memory exception

this.physics.scene.add.tileSprite(0, 0, 50000, 50000, ‘atari’);

I search a lot in phaser examples and can’t find solution.


Failed to execute ‘getImageData’ on ‘CanvasRenderingContext2D’: Out of memory at ImageData creation
Why it occurs? Should i set up any any extra value to use tileSprite?

Hi, I think 50000 is too big…
try it with lower values, also it probably depends on the memory of the device

But i need 50000. in phaser 2 was’t any problem with tileSpeite.
i use 50000 value. But phaser 3 reach out of memmory…
What is the difference between tileSprite in 2 and 3 phaser?

I really don’t know, maybe it’s because in Phaser 2 PIXI was managing it in a different way. Let’s see if someone can bring more light on this…
Anyway I think a workaround can be create tileSprites to the limit, position them and manage them all as a bigger one.

1 Like

Thank for advise. Do you have any example where i can see how to manage small tileSprite like big tileSprite?

No, it was just an idea, but it really depends on…
Why do you need width and height of 50000?
How do you use it? What are you trying to achieve?

1 Like

You can create a small tileSprite and change the position.

1 Like

A TileSprite isn’t meant to be that big. You’ll want to use a smaller tilesprite and then change its tilePositionx and tilePositionY properties to “scroll” it. The sprite itself won’t actually change position. See https://labs.phaser.io/edit.html?src=src\game%20objects\tile%20sprite\Example%20-%20Canvas.js for an example

1 Like

At a cursory glance, Tile Sprites are handled similarly in Phaser 2 and Phaser 3, so I’ve got no idea why Phaser 2 can works. At any rate, 50000 is a really big size, larger than pretty much any GPU can handle. As the documentation says, use a smaller size and adjust the tilePosition and the tileScale. Those two properties can emulate pretty much any size.

1 Like