# Performance of really big tile maps

**URL:** <https://phaser.discourse.group/t/performance-of-really-big-tile-maps/1192>\
**Category:** Phaser 3\
**Created:** [February 12, 2019, 8:08pm UTC](https://phaser.discourse.group/t/performance-of-really-big-tile-maps/1192 "2019-02-12T20:08:29Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![aylictal](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@aylictal](https://phaser.discourse.group/u/aylictal)\
**Post date:** [February 12, 2019, 8:08pm UTC](https://phaser.discourse.group/t/performance-of-really-big-tile-maps/1192/1 "2019-02-12T20:08:29Z")

</div>

Hello,

I am looking for a solution to have a really big tilemap loaded at run time and get the best performance I possibly can.

As of now the performance is degrading slightly due to how big of a json file i am loading into phaser is causing lower end machines to crawl down to 15-20fps which is unplayable.

Has anyone come up with a clever way to load big tiled maps without performance degrading, and without introducing transitions from one map to another? (in other words rollovers via legend of zelda 1 on NES isn’t viable solution)

Another question: Does phaser render stuff outside of the current screen (or canvas) bounds? Or do we need to specify that in an option somewhere?

Thanks.

---

<div class="post-metadata">

**Author:** ![jackfreak](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@jackfreak](https://phaser.discourse.group/u/jackfreak)\
**Post date:** [February 12, 2019, 8:32pm UTC](https://phaser.discourse.group/t/performance-of-really-big-tile-maps/1192/2 "2019-02-12T20:32:38Z")

</div>

How big is your map in tiles (width x height) ?

Phaser does not render anything outside of the current screen, but it might process those gameobejcts/tiles anyway (not the rendering phase). If you need speed, try creating a StaticTilemapLayer instead of a Dynamic one.

An interesting read might be this article:

> **[Modular Game Worlds in Phaser 3 (Tilemaps #3) - Procedural Dungeon](https://itnext.io/modular-game-worlds-in-phaser-3-tilemaps-3-procedural-dungeon-3bc19b841cd?gi=fc4dc624d6af)**
>
> Building an endless, procedurally generated dungeon world

---

<div class="post-metadata">

**Author:** ![aylictal](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@aylictal](https://phaser.discourse.group/u/aylictal)\
**Post date:** [February 12, 2019, 9:33pm UTC](https://phaser.discourse.group/t/performance-of-really-big-tile-maps/1192/3 "2019-02-12T21:33:13Z")

</div>

Tiles are 1000 wide / 1000 high == 1million tiles  
Tiles are 16 pixels / 16 pixels == 256 pixels.

---

<div class="post-metadata">

**Author:** ![Antriel](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/antriel/32/15_2.png) [@Antriel](https://phaser.discourse.group/u/Antriel)\
**Post date:** [February 13, 2019, 6:40am UTC](https://phaser.discourse.group/t/performance-of-really-big-tile-maps/1192/4 "2019-02-13T06:40:32Z")

</div>

> [@jackfreak](#):
>
> Phaser does not render anything outside of the current screen

Only dynamic tilemaps are culled afaik. Static ones can’t be culled and for general game objects I think you need to do it manually (using `visible` or `alpha`). There is a method in camera to get a list of culled objects, but with such high amounts you would need to handle it in customized, optimized way.

Try dynamic layer, although that might still be too slow. Solution would be to load/unload the map in segments so there’s never too much to work with.

---

<div class="post-metadata">

**Author:** ![aylictal](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@aylictal](https://phaser.discourse.group/u/aylictal)\
**Post date:** [February 13, 2019, 2:38pm UTC](https://phaser.discourse.group/t/performance-of-really-big-tile-maps/1192/5 "2019-02-13T14:38:17Z")

</div>

Yeah it unfortunately needs to be static as part of requirements I’m setting on it ☹

---

<div class="post-metadata">

**Author:** ![Antriel](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/antriel/32/15_2.png) [@Antriel](https://phaser.discourse.group/u/Antriel)\
**Post date:** [February 13, 2019, 3:36pm UTC](https://phaser.discourse.group/t/performance-of-really-big-tile-maps/1192/6 "2019-02-13T15:36:09Z")

</div>

What requirements are those? Dynamic can do more than static, so unless I’m missing something there’s no possible valid requirement except performance, which is what we are trying to improve here.

---

<div class="post-metadata">

**Author:** ![aylictal](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@aylictal](https://phaser.discourse.group/u/aylictal)\
**Post date:** [February 13, 2019, 3:41pm UTC](https://phaser.discourse.group/t/performance-of-really-big-tile-maps/1192/7 "2019-02-13T15:41:24Z")

</div>

It needs to be static because it needs to be static? 🙂

I could try loading it dynamically but the map is not going to change (Im speaking in terms that no sort of procedural generation is going to occur). I guess you could say it is “business level requirements that the map remains consistent and always renders the same”.

---

<div class="post-metadata">

**Author:** ![Antriel](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/antriel/32/15_2.png) [@Antriel](https://phaser.discourse.group/u/Antriel)\
**Post date:** [February 13, 2019, 3:53pm UTC](https://phaser.discourse.group/t/performance-of-really-big-tile-maps/1192/8 "2019-02-13T15:53:44Z")

</div>

It’s just about what kind of layer you create. If you don’t change the tiles, it will render the same.

---

<div class="post-metadata">

**Author:** ![aylictal](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@aylictal](https://phaser.discourse.group/u/aylictal)\
**Post date:** [February 13, 2019, 4:02pm UTC](https://phaser.discourse.group/t/performance-of-really-big-tile-maps/1192/9 "2019-02-13T16:02:40Z")

</div>

WOW. You guys are freaking awesome!

Changing from static to dynamic and fps on this crap work machine I’m using went from ~31-33 fps to ~58-60 (and i’m clamping fps to 60 manually).

INCREDIBLE. Thank you so much. Literally worked like a charm without changing anything but createStaticLayer to createDynamicLayer. Loading 1million tiles with this is awesome.

---

<div class="post-metadata">

**Author:** ![jackfreak](https://avatars.discourse-cdn.com/v4/letter/j/919ad9/32.png) [@jackfreak](https://phaser.discourse.group/u/jackfreak)\
**Post date:** [February 14, 2019, 5:25am UTC](https://phaser.discourse.group/t/performance-of-really-big-tile-maps/1192/10 "2019-02-14T05:25:31Z")

</div>

@Antriel was right, I forgot StaticTilemaps aren’t culled. But they are super fast for small maps for that very same reason. On the contrary, they are super slow for giant maps. Richard explained this very clearly in this devlog if you are curious: [https://phaser.io/phaser3/devlog/122](https://phaser.io/phaser3/devlog/122)
