pixijs / particle-emitter

A particle system for PixiJS
http://pixijs.io/particle-emitter/docs
MIT License
786 stars 124 forks source link

Main thread gets frozen if emitter.update receives too big number #142

Closed antmelnyk closed 2 years ago

antmelnyk commented 3 years ago

If emitter.update receives very big number (like 10000000) as parameter, it will hang up the browser page. Particle limit had 500, spawn frequency 0.8.

Maybe is quite obvious that we should not pass big numbers into it as it expects the seconds elapsed since last update, but at least would be nice to have some fool-proof or warning. I've spend quite some time trying to figure out the bug (in my code accidentally passed big delta into the update call).

andrewstart commented 3 years ago

Hmm, the threshold for "too large" would be dependent on emitter settings (frequency + particle lifetime), and to detect said value and particularly to reduce the delta to an acceptable value would require a bit of math that I'd rather not do each frame given the rarity of someone improperly passing in too large an update value.

antmelnyk commented 3 years ago

Fair enough. Of course the performance of emitting itself is more important than some edge case which is developer mistake anyway. I think we can close the issue 😊

Maybe would be nice to add some notice to the docs or method description, but is up to you of course, whether it's worth noticing with details regarding frequency and lifetime settings.