The particle emitter can encounter undefined particles which casues it to choke and break
aaclayton opened this issue · comments
Using version 5.0.7"
I'm afraid I don't have a clean reproduction case for this, but my situation is that I sometimes destroy and remove a particle emitter and construct a new one. At times during this process when a new emitter is first constructed, it can encounter an update
loop in the ticker where some particle is undefined
. I don't know why the particle is undefined, but the issue shows up starting in the following loop:
for (let particle = this._activeParticlesFirst, next; particle; particle = next)
{
in cases that particle
is undefined
- the loop eventually crashes at:
if (this.updateBehaviors[i].updateParticle(particle, delta))
Sorry this isn't much to go on, I hope you might have a theory upon seeing this report. Let me know if I can provide any further detail that would be helpful.
So it isn't particle
that is null, but particle.transform
(inside the particle.scale
getter), due to the particle having been destroyed (normally inside destroying the emitter). Because Emitter.destroy()
pretty thoroughly clears both the particle references and the behaviors that would allow Emitter.update()
to do anything when it runs, it seems that somehow a particle that belongs to a running emitter is getting destroyed rather than a destroyed emitter continuing to run. The other possibility of a destroyed particle finding its way to a new emitter seems less likely, as Emitters do not pool particles at all.
I hope this gives you enough direction to look for a cause within your code. I'm not completely ruling out a bug in the library in some rare condition, but if that is the case it isn't something that I can suss out without a running example.
Thanks @andrewstart - I'll look into it and see if I can figure out some sort of repro case. I am certainly not doing anything to call destroy on individual particles, I only ever destroy the emitter itself.
Hi @andrewstart I was able to identify the problem and resolve it. I was toggling off the emit
property for each emitter and later destroying them - but there was a timing issue where I was calling ParticleEmitter#destroy
after a parent PIXI container was called with destroy({children: true})
. Sorry for the false alarm.