Sub anim instance crashes

I’ve found a couple of crashes while trying to set up anim blueprints using sub anim instances. I’ve attached two graphs that cause crashes and the sub graph that both use (which just has a single animation hooked into it).

The first network (TestAnim_CompileCrash) crashes when compiling the anim blueprint. It’s a state machine with two states: Idle (which has a single anim hooked up to it) and Walk (which has the sub graph hooked up to it). Idle is the default state. If you put TestAnimSub as the sub anim graph inside the Walk state then the editor crashes when you compile (I’ve left it unhooked otherwise you can’t open the blueprint).

The second network (TestAnim_RuntimeCrash) crashes at runtime. It’s the same as the previous graph, except that Walk is the default state. If you hook that up to a character, it’ll transition to the Idle state, wait five seconds, then try to transition back to the Walk state, at which point it crashes. I think it’s crashing in InitializeAnimation() in AnimInstance.cpp on a call to GetProxyOnGameThread(), which fails because it’s not on the game thread.

We’ve used sub anim instances on the top layer of the anim graph without a problem, except that if you hook up a montage slot after it then the sub graph pauses rather than resetting when you play a montage. Putting the sub graph inside a state makes it reset, but it results in the crashes above.

Hi Alison,

Thank you for reporting the crash. I have entered UE-36900.

Have you reported the issue where you cannot use Sub Anim Instances in line with a slot that has a Montage playing on it?

-Matt W.

Hi again Alison,

I’ve just checked in a fix for this issue in CL#3153175. Essentially the initialize call was being called from the node initialize which for states can happen off the game thread if they weren’t hit by the original initialize. We do have a different initializer that’s guaranteed to hit all nodes from the game thread when we set up the animation instance. Moving the call into this initializer fixes the issues with the blueprints you provided.

Thanks again for the report, apologies for the inconvenience!

Benn.

Thanks. Have you entered a bug for the second crash? Or is that fixed already?

We can use the sub anim instance with the montage slot after it, it just doesn’t do what we wanted it to do. But I’m not sure if that’s by design or not. If you had an anim followed by a montage slot, would you expect the anim to restart after the montage finishes playing or should it continue from where it was when the montage started? States reset in that scenario but anims don’t, and the sub anim instance is treated as an anim.

Hi Alison,

I’m taking a look at this now, I’ve managed to reproduce the crash with your assets, and I think I’m zeroing in on a fix. I’ll get back to you soon.

Thanks for the report,

Benn.

Just to note, this fix should resolve both crashes that you reported.