Lag with phaser.min.js, not with phaser.js

Hi,

I made/copied a small Phaser 3 app to learn, following this tutorial:
https://yorkcs.com/2019/02/25/top-down-infinite-terrain-generation-with-phaser-3/

It lags everytime assets are unloaded. However, if I change it to non-minified version of phaser.js, it does not lag. It lags only with phaser.min.js. How is this possible? They shouldn’t be different in anyway am I right?

Github repo: https://github.com/Borche/phaser-terrain-generation

// Phaser newbie (although not new to programming)

It lags when exactly, and how?

Using the ASDW keys you can move about in the game. Terrain is loaded and unloaded as you move about. When terrain “chunks” are unloaded, it freezes for a second or so.

If I use the phaser.js instead of the phaser.min.js, it doesn’t lag. Also, if I override the tiles destroy function, like so:
tile.destroy = function() {}
it doesn’t lag.

I would like to know why…! :slight_smile:

In that repo phaser.js is v3.16 but phaser.min.js is v3.21.

Yes. But there is also phaser.new.js which is non-minified, v 3.21, which does not lag, while the minified 3.21 does.

For me, phaser.new.js lags as well.

I think the problem is just that 1024 sprites are being destroyed for each unloaded chunk.

@samme : I’d like to know too! This looks like a pretty neat project! :slight_smile:

1024 sprites being destroyed sounds like much but I don’t know if that number is high or low really, I’m new to game programming.

But a thought I had when you said that. May this be a problem that occurs because Javascript it single-threaded? In another language, say Java/C# you would probably do that work in a separate thread while the main thread/GUI-thread continues displaying frames, and add the result of the separate thread to the GUI once calculations have completed?

How do you fella game-programmers deal with javascript being single-threaded? Or is it normally not a problem?

Anyone?

I’m not sure on that point.

Mostly that example would benefit from object pooling or a different game object type (Blitter, DynamicTilemapLayer).

Thanks for those links and advice. :slight_smile:

Also, in that example you can reduce chunkSize from 16 to 7 or 8. I think 16 was for an unzoomed camera.

Thanks, I will try this when I get home.

@borche : would be nice to see your results in a demo! :slight_smile: