Pixi.js: [Question] Is it normal to see occasional "lag spike"s?

Created on 24 Mar 2019  ·  3Comments  ·  Source: pixijs/pixi.js

Question

Is it normal to see occasional (once-every-few-seconds) dips in framerate to anywhere about 0~30 FPS? (normal is 60 FPS) Logging app.ticker.FPS, I see dips every so often that only last for like one frame and have no visible effect on the actual smoothness of the game (but I multiply everything out by delta so that might be why I can't notice the lag spikes).

Environment

  • pixi.js version: v5.0.0-rc.2
  • Browser & Version: Chrome Version 72.0.3626.121 (Official Build) (64-bit)
  • OS & Version: OSX 10.14.3
  • Running Example: https://m00nr4bb1t.github.io/jrpg.js/

Most helpful comment

Not sure if this is the case here but usually these types of dips are because of garbage collection. If you are creating and destroying objects over and over it will require these unsightly hiccups. The common way to mitigate is to pool the objects and recycle them instead of creating a new one and throwing it away. Here’s some info on that: https://www.html5rocks.com/en/tutorials/speed/static-mem-pools/

All 3 comments

Not sure if this is the case here but usually these types of dips are because of garbage collection. If you are creating and destroying objects over and over it will require these unsightly hiccups. The common way to mitigate is to pool the objects and recycle them instead of creating a new one and throwing it away. Here’s some info on that: https://www.html5rocks.com/en/tutorials/speed/static-mem-pools/

Thank you, I did some GC optimization (I was creating a new function every update call, uwu) and the lag spike seems to be gone (at least for the most part)! For any future viewers, http://buildnewgames.com/garbage-collector-friendly-code/ this article also helped out a lot.

Closing this now :)

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings