Search Unity

Bug Rig breaks when used with the Timeline

Discussion in 'Animation Rigging' started by calpolican, May 9, 2023.

  1. calpolican

    calpolican

    Joined:
    Feb 2, 2015
    Posts:
    425
    VERSION: Using Unity 2021.3.15, AnimationRigging 1.1.1.

    THE ISSUE: I've had lots of issues with the error "System.InvalidOperationException: The TransformStreamHandle cannot be resolved." I consider it a huge problem of this package since it has appeared many times, and it often leads to memory leaks. Finally I got things working (even with some instantiated characters), but I'm seeing now this error as soon as the first frame of a timeline animation is rendered, with a non-instanciated character.

    A WORKAROUND: I was able to find a work around disabling the RigBuilder for the first frame of the Timeline animation, and enabling it back at the end of the frame. I post this, as it may give a clue as to what could be in conflict, and provide a workaround for anybody with the same issue. Turning it off and on without waiting for the end of the frame doesn't work. The warnnings are still shown (Could not resolve 'x' because it is not a child Transform in the Animator hierarchy) but the error is gone.

    MY RIG'S HIERARCHY (simplified):
    -GameObject with AnimatorComponent.
    +Model
    +Skeleton
    +RIG(gameobject with rig component)
    >AIM rig (gameobject with rig component)
    >>Aim constrain for hips (GO with multiAimConstrain)
    >>Aim constrain for Spine 1 (GO with multiAimConstrain)
    >>Aim constrain for Spine 2 (GO with multiAimConstrain)
    >AIM target (gameObject with multiparent constrain component that's referenced by each Aim constrain)

    NOTES:
    > There are no duplicate names inside the hierachy. Though, since I use the same rig prefab for other characters, there are other hiercachies with the same names in the scene.
    > There's a parent object for the rig with a rig component that shouldn't necesarily be there. It's there because initially I thought that it was possible to have a master rig slider that controls the rig weights of all children (something that you should probably add to the package). Now it's only used for arrangement reasons and because it controls the target's multiParent's constrain.
    > The way the timeline is working, is by binding to the character's animator at runtime using PlayableDirectorActive.SetGenericBinding(track, character.animator); I mention this because I think this could potentially be changing the Playable graph and perhaps generating the issue.
    > The same issue is not happening with the instantiated characters that also have the same rig scheme. I couldn't find the reson as they're quite similar. Still, for those to work I had to set inactive the object holding the animator and then active again in the first frame. This re-initialized the animator wich allowed me to enable the rigbuilder without issues. As mentioned, for whatever reason, they're not generating the bug mentioned here.
     
    Last edited: May 9, 2023
  2. fleity

    fleity

    Joined:
    Oct 13, 2015
    Posts:
    345
    I've had the same error last week in our slightly unusual animation setup which ultimatively resulted in the entire engine crashing. (Although 2022.2.13 and Animation Rigging 1.2.1). I had build the Rig graph into the Animator Controller graph to evaluate them together on a fixed timestep (bad idea do not do that) (and during timeline preview).

    Try disabling burst (Jobs>Burst>Enable Compilation) and you might get a more detailed callstack. For me the issue originated in a function of the animation rigging package where an array is going out of range without being managed.

    It sounds to me as if some parts of your playable graph go out of scope and are cleaned up while others still exist and try to evaluate. But if you are not messing with the playable api yourself that should not happen.