HappinessSam Posted December 6, 2017 Share Posted December 6, 2017 I'm trying to use some spine animations in a large Pixi application at work. It's mostly working but I'm getting intermittent runtime errors coming from the Spine objects. This error is:Uncaught TypeError: Cannot read property 'transform' of null at Spine.e.updateTransform (pixi.min.js:formatted:4401) at Spine.autoUpdateTransform (Spine.ts:479) at e.updateTransform (pixi.min.js:formatted:4405) at e.updateTransform (pixi.min.js:formatted:4405) at GameScene.e.updateTransform (pixi.min.js:formatted:4405) at e.render (pixi.min.js:formatted:8605) at Function.ScenesManager.loop (ScenesManager.ts:273) at t.emit (pixi.min.js:formatted:13126) at t.update (pixi.min.js:formatted:13068) at _tick (pixi.min.js:formatted:12988) The error is coming from PIXI.Container, line 323 because this.parent is null. This is a bit bonkers because this is only being called because the spine object is in the children list of the scene being rendered. this.transform.updateTransform(this.parent.transform); I dug in a tried to isolate the problem and found that somewhere in the Spine update function the parent was being set to null. In Chrome debugger I put in some conditional breakpoints for dt>0 && this.parent==null and found that the culprit was line 184 this.state.apply(this.skeleton); Before this line the breakpoint doesn't trigger, after it it does, with this.parent being null. I had a read through AnimationState.apply and I can't for the life of me see anything that would be setting the Spine parent state. So my question is can anybody else see anything in there that might be creating this effect? I should say that the application does a bunch of complicated pooling of symbols, so the Spine object might be getting removed and sent back to the pool then re-added frequently. But my understanding was that since JS is mostly single threaded if this.parent exists on line183 but not 185 something between there must be setting it to null. I'm not extending or doing anything else to the Spine object. Unfortunately I can't give out any coded to show the context. I'd be really grateful if anybody has any suggestions or input. ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 6, 2017 Share Posted December 6, 2017 Heh, nice one. We have to add guart in auroUpdateTransform - if object was removed after update(0) , dont do updateTransform. Better if you created an issue in pixi-spine repo for that, but here is fine too. https://github.com/pixijs/pixi-spine/blob/master/src/Spine.ts#L469 PIXI.spine.prototype.autoUpdateTransform = function() {... if (!this.parent) return; ... } However there will be side effects - neighbour updateTransform() wouldnt be called because that all exists in a loop inside updateTransform of parent. Better solution is to switch all autoUpdates (Spine.globalAutoUpdate=false or autoUpdate of every instance), and manually call update() from your game loop. autoUpdateTransform is a great hack, it exists because pixi doesnt have animation loop. HappinessSam 1 Quote Link to comment Share on other sites More sharing options...
HappinessSam Posted December 6, 2017 Author Share Posted December 6, 2017 Thanks! That's great info. I think I will look into manually call update, as that looks safer. ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 6, 2017 Share Posted December 6, 2017 Yep, that's recommended action. I hope we'll add animation loop in v5 and it'll be easier. Quote Link to comment Share on other sites More sharing options...
HappinessSam Posted December 6, 2017 Author Share Posted December 6, 2017 This has worked fine and touch wood is working perfectly now. I was also getting an occasional flickering issue which has cleared up after setting the spine's autoupdate to false and updating manually - maybe this apporach would fix https://github.com/pixijs/pixi.js/issues/4117 too. ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 6, 2017 Share Posted December 6, 2017 Good. Now only if that guy gives me complete fiddle and not scraps... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.