Jump to content

Pixi Spine runtime error


HappinessSam
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...