pixijs / particle-emitter

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

TypeError: Cannot read property '_uvs' of undefined #26

Closed pawelstan closed 8 years ago

pawelstan commented 8 years ago

Hey!

I have a problem with error:

TypeError: Cannot read property '_uvs' of undefined

Its show really randomly, hard to create a reproduction. The problem is with AnimatedParticle.

TypeError: Cannot read property '_uvs' of undefined
    at SpriteRenderer.render (http://localhost:5000/bower_components/pixi/bin/pixi.js:18475:22)
    at Sprite._renderWebGL (http://localhost:5000/bower_components/pixi/bin/pixi.js:17948:29)
    at Sprite.Container.renderWebGL (http://localhost:5000/bower_components/pixi/bin/pixi.js:7744:14)
    at Container.renderWebGL (http://localhost:5000/bower_components/pixi/bin/pixi.js:7749:30)
    at Container.renderWebGL (http://localhost:5000/bower_components/pixi/bin/pixi.js:7749:30)
    at WebGLRenderer.renderDisplayObject (http://localhost:5000/bower_components/pixi/bin/pixi.js:14661:19)
    at WebGLRenderer.render (http://localhost:5000/bower_components/pixi/bin/pixi.js:14634:10)

Do you have any advice what to look for to better track the issue? So I can say more? Using the latest 1.6.6

Cheers, P.

andrewstart commented 8 years ago

It seems that it is trying to render a Sprite somewhere that has no texture, so the Sprite was probably destroyed but left on the display list. It could also be possible that your AnimatedParticle art data is not formatted correctly - see http://pixijs.github.io/pixi-particles/docs/classes/PIXI.particles.AnimatedParticle.html. If you are using the { texture: "textureName", count: 3} format, but the texture property doesn't exist or is misnamed, then that would probably try to use undefined as a texture.

pawelstan commented 8 years ago

The fun part is that this occurs occasionally without any changes in code or config. Also I havn't found any solid reproduction. Just happens from time to time.

I would go with the "Sprite with no texture", what I can manually destroy to be sure empty sprite is not rendered?

andrewstart commented 8 years ago

Sorry, I missed your response until now. Were/are you using a ParticleContainer or a regular Container? Upon looking at my cleanup/destruction code, it looks like any particles that are waiting in the pool when an Emitter is destroyed won't get removed from a ParticleContainer.

pawelstan commented 8 years ago

Hey!

I'm using regular Container cause I need color transform functionality + animatedParticle. When using ParticleContainer, I dont have this issue. So something opposite of your find ;)

pawelstan commented 8 years ago

I dont think there was a memory leak in ParticleContainer, we double checked that, all was disposed correctly, but I have this issue with TypeError: Cannot read property '_uvs' of undefined in regular Container.

Maybe something is disposed too soon in regular Container? That's why I have this error?

andrewstart commented 8 years ago

Unless you are destroying Emitters in the middle of a render, I don't think it's possible to destroy stuff too soon.

andrewstart commented 8 years ago

I've done some general improvements to improve library stability, including making sure destroyed particles get orphaned and making it much more difficult to have a particle without a texture. If you test with the build currently on master, do you still get errors?

pawelstan commented 8 years ago

Great! thanks! checking

pawelstan commented 8 years ago

We checked, seems issue is fixed! I will do some more tests later on to be 100% sure. Thanks!

pawelstan commented 8 years ago

I think this is a good reason to build a 1.6.7 ;) would help us with our production release too ;)

andrewstart commented 8 years ago

So it was written, so it shall be (and is).

roybein commented 1 year ago

animationSpeed is undefined may lead to this Error.