[bug] PIXI.extras.AnimatedSprite: Texture undefined upon adding to scene

User: Poryg
Bug: After you use SceneManager._scene.addChild(animSprite), that sprite will lose its' texture (becomes undefined), which will result in a "Cannot read _updateID (webGL)/ _frame (canvas) of undefined". Bug in both Canvas and WebGL.
How to Replicate the Bug:
  • Make a PIXI.extras.AnimatedSprite (which consists of loading several images into PIXI.utils.textureCache and then using animatedSprite = new PIXI.extras.AnimatedSprite (mandatory: textures, optional: boolean animated))
  • Add it to the scene as you would add any other PIXI.Sprite (through SceneManager._scene.addChild(animatedSprite))
    That is an important step, because before you use SceneManager._scene.addChild(animatedSprite), you can see that the animated sprite still has its' texture!
  • See that it does the same error
  • The bug is replicated in the project, event in top left corner.
Other: Post screenshots of the bug, videos, etc. Anything that will make it more clear for us in order to fix.

Project link:
https://drive.google.com/open?id=0BytvRXrFbIpHVGVRRDcwLUtld28

Screenshots from the console (the only relevant screenshots I can give):

WebGL error
Screenshot_205.png

Canvas error

Screenshot_206.png

Before you use SceneManager._scene.addChild (animatedSprite)
Screenshot_207.png

After you use SceneManager._scene.addChild(animatedSprite)
Screenshot_208.png
Array[2] doesnt mean that there are no "undefined" in that array. Are you sure?
Yes, @Hackerham, there is nothing undefined in _textures. But that's not what is the problem. The problem is _texture.
If you see, the first picture contains _texture = Texture. In other words the _texture contains valid data about the texture the animated sprite is currently on.
However, the moment you use SceneManager._scene.addChild, the data from
_texture becomes undefined. In other words the current texture the animated sprite is on becomes undefined.
_textures never change and will always carry valid data about the textures the animated sprite is supposed to go through. But _texture, in other words the current texture, disappears. So yes, I am sure it is a bug.
Do you have something in "watch" section of debugging tools that can affect that? RMMV does not override any "addChild", also AnimatedSprite does not have special handlers for "added" event.

I dont have other ideas, now the only way I can help you if you give me complete example that I can run and see it for myself. Or may be some more info will be enough?

btw, beware that AnimatedSprite uses pixi shared ticker, which is separated from RMMV event loop.
I have already shared the project where the bug is replicated. You can download it from the first post and run it, the event that replicates the bug is an autorun event (located in the top left corner of the map, so you can see it for yourself) .
However, if you wish to replicate the bug, you need to do these three steps.
1. Load some pics into PIXI.TextureCache. Preferably put them in an array for easier manipulation. I use PIXI.Texture.fromImage for it, since pixi for rmmv doesn't have a pixi loader for some reason.
2. Create an animated sprite from them.
animSprite = new PIXI.extras.AnimatedSprite (array with textures)
3. SceneManager._scene.addChild (animSprite)
Or if you want, you can take a look at the project on the first post. There's an event that replicates the bug,

I don't think the addChild is at fault, because non-animated sprites (PIXI.Sprite and PIXI.Text) work just fine. I think there's something wrong with the function that is responsible for updating the animated sprite. The pixi ticker or whatever it is. Or maybe with the communication between pixi ticker and rmmv update function.

That's all the information I can provide.
I don't use any debug tools or anything out of the ordinary. I use only rpg maker.
This may interest you.
I have managed to get the animated sprite to work, there are two conditions though.
First condition is, I have to remake the game so that it works under PIXI ticker. Or if not the game, then at least particular container that sprite is on. Which probably requires default PIXI version too, because if I create a pixi ticker in MV's PIXI, it crashes instantly once I run that ticker.
Second condition is, I have to run the sprite under a container that is not MV's default container. Doesn't matter if it is SceneManager._Scene, window layers or whatever. If I add it under any of MV's default container, the error appears. However, if I create a fresh PIXI container, add the animated sprite as its' child and then add it to SceneManager._scene, it works like a charm.
If I find the culprit, I'll share it here, just from the interest of it. Because since animated sprite is unusable without PIXI ticker, it's completely pointless to fix this bug.
I found the reason of this issue, this is because of Scene_Base will call it's children's update method without arguments, but AnimatedSprite needs a delta parameter to work. Wrap AnimatedSprite inside some PIXI Container is a good workaround.
As for PIXI.ticker, you can check my post: https://forums.rpgmakerweb.com/inde...ker-shareds-_tick-callback.98565/#post-892395

Original thread: https://forums.rpgmakerweb.com/threads/bug-pixi-extras-animatedsprite-texture-undefined-upon-adding-to-scene.83765/