Search Unity

Bug? Possible conflict between RigBuilder and sequences

Discussion in 'Virtual Production' started by akent99, Jun 30, 2021.

  1. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    588
    Reporting in case a problem with sequences beta - not sure. I use "RigBuilder" from Animation Rigging 1.0.3 (Unity package to allow you to do overrides in a timeline, https://docs.unity3d.com/Packages/com.unity.animation.rigging@0.2/manual/index.html). But as I flip around my scene with sequences, I am seeing the error below in the log. I am wondering if jumping between timelines is getting it confused

    upload_2021-6-30_1-14-31.png

    The stack trace is

    MissingReferenceException: The object of type 'RigBuilder' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    UnityEngine.Animations.Rigging.RigBuilder.StopPreview () (at Library/PackageCache/com.unity.animation.rigging@1.0.3/Runtime/AnimationRig/RigBuilder.cs:157)
    UnityEditor.Timeline.WindowState.OnStopPreview () (at Library/PackageCache/com.unity.timeline@1.5.2/Editor/State/WindowState.cs:994)
    UnityEditor.Timeline.WindowState.set_previewMode (System.Boolean value) (at Library/PackageCache/com.unity.timeline@1.5.2/Editor/State/WindowState.cs:253)
    UnityEditor.Timeline.WindowState.Reset () (at Library/PackageCache/com.unity.timeline@1.5.2/Editor/State/WindowState.cs:440)
    UnityEditor.Timeline.TimelineWindow.OnBeforeSequenceChange () (at Library/PackageCache/com.unity.timeline@1.5.2/Editor/Window/TimelineWindow_ActiveTimeline.cs:52)
    UnityEditor.Timeline.WindowState.SetCurrentSequence (UnityEngine.Timeline.TimelineAsset timelineAsset, UnityEngine.Playables.PlayableDirector director, UnityEngine.Timeline.TimelineClip hostClip) (at Library/PackageCache/com.unity.timeline@1.5.2/Editor/State/WindowState.cs:377)
    UnityEditor.Timeline.TimelineWindow.SetCurrentTimeline (UnityEngine.Timeline.TimelineAsset seq, UnityEngine.Playables.PlayableDirector instanceOfDirector, UnityEngine.Timeline.TimelineClip hostClip, System.Boolean force) (at Library/PackageCache/com.unity.timeline@1.5.2/Editor/Window/TimelineWindow_ActiveTimeline.cs:43)
    UnityEditor.Timeline.TimelineWindow.SetCurrentTimeline (UnityEngine.Playables.PlayableDirector director, UnityEngine.Timeline.TimelineClip hostClip) (at Library/PackageCache/com.unity.timeline@1.5.2/Editor/Window/TimelineWindow_ActiveTimeline.cs:29)
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <695d1cc93cca45069c528c15c9fdd749>:0)
    UnityEditor.Sequences.TimelineUtility.PushItemIntoBreadcrumb (UnityEngine.Playables.PlayableDirector director, UnityEngine.Timeline.TimelineClip hostClip) (at Packages/com.unity.sequences@1.0.0-pre.6/Editor/Utilities/TimelineUtility.cs:111)
    UnityEditor.Sequences.TimelineUtility.RefreshBreadcrumb (UnityEditor.Sequences.TimelineUtility+TimelinePath path) (at Packages/com.unity.sequences@1.0.0-pre.6/Editor/Utilities/TimelineUtility.cs:133)
    UnityEditor.Sequences.SelectionUtility.TrySetTimelineInContextOf (UnityEngine.Playables.PlayableDirector director) (at Packages/com.unity.sequences@1.0.0-pre.6/Editor/Utilities/SelectionUtility.cs:137)
    UnityEditor.Sequences.SelectionUtility.OnEditorSelectionChanged () (at Packages/com.unity.sequences@1.0.0-pre.6/Editor/Utilities/SelectionUtility.cs:83)
    UnityEditor.Selection.Internal_CallSelectionChanged () (at <9540aba417024bb296674f70fa788b73>:0)

    The section of code appears to be:

    void OnStopPreview()
    {
    if (m_PreviewedComponents != null)
    {
    foreach (var previewComponent in m_PreviewedComponents)
    {
    if (previewComponent != null)
    {
    previewComponent.StopPreview();
    }
    }
    m_PreviewedComponents = null;
    }

    It appears the RigBuilder instance has been destroyed, but it is still in the previewComponent list.

    I don't have precise instructions to repeat sorry - the following is to the best of my memory. I have a character with the RigBuilder script in the scene (the only character so far) and dropped a walk animation clip onto it. Hmmm, to be precise, I added "Bear" (character's name) into the scene first using Sequence Assembly, then deleted the Sequence Asset Track from the timeline and added my own Animation Track so I could drop the animation clips directly into it (rather than creating a variant per animation). But then I realized I needed to use "Bear carrying Bag" (a variant of Bear). I used Sequence Assembly to pick the variant. This deleted Bear from the scene and added Bear carrying Bag, but that messed up the animation track as Bear was deleted. I was trying to drop the new Bear carrying Bag from the scene into the timeline for that animation track but it was failing. That is when I noticed the error message. So maybe the problem was swapping the character Bear with a variant Bear carrying Bag got things confused as my timeline was still using the old object...???

    upload_2021-6-30_1-23-34.png

    upload_2021-6-30_1-24-7.png

    Notice in the timeline I also have "Bear" as a track under Character but it references "Bear carrying Bag" - I think that got added back in when I swapped the character from "Bear" to the variant "Bear carrying Bag".

    upload_2021-6-30_1-25-40.png

    But I cannot now delete the "Bear" track above (I pick "Delete" from right clicking, but it does not delete and I get the error in the Console) and I cannot drop "Bear-v11-2 Prefab Variant" under "Bear carrying Bag" in the scene into the first track under "Character" (where it says "None (Animator)") - again nothing happens (except error is added to the log).

    I will restart Unity and try again later - capturing details while I can.
     
  2. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    588
    Oh, I tried one last thing - exiting and restarting Unity cleared the problem. I was able to delete the Sequence Asset Track and drop the character back into the animation track after restart.
     
  3. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    588
    I started talking about options on another thread, then went a bit further and got exactly the game object tree for a character to work in a plain Timeline with Animation Rigging working but fail in a Timeline inside a Sequences package. I included a few more stack traces https://forum.unity.com/threads/ways-to-animate-picking-up-an-object.1165652/#post-7492862 (should have put them on this thread sorry).

    So basically, Animation Rigging looks great, but I get Console stack traces and it does not work when used with the Sequences package, but a copy/paste does work in another Scene with a simple Timeline without Sequences.
     
  4. thomastt_unity

    thomastt_unity

    Unity Technologies

    Joined:
    Nov 6, 2018
    Posts:
    12
    Hi @akent99,
    Apologies for the lack of response in this thread. I'm going to check this out with the team and come back to you.
     
    akent99 likes this.
  5. thomastt_unity

    thomastt_unity

    Unity Technologies

    Joined:
    Nov 6, 2018
    Posts:
    12
    Hey @akent99, I confirm there is a bug when switching a SequenceAsset containing a RigBuilder component to a variant. I filed a ticket on our end to get this fixed. Thank you for reporting this.

    In the meantime, it seems toggling off "Preview" (button at the top-left in Timeline) before doing such operation on a SequenceAsset with a RigBuilder prevents this from happening.
     
    HIBIKI_entertainment and akent99 like this.
  6. ellka

    ellka

    Unity Technologies

    Joined:
    Jun 17, 2019
    Posts:
    71
    Hey @akent99, I spent some time investigating this bug a few days ago and realized it was not necessarily a Sequences problem (at least the source of the problem is not in Sequences itself). And so, I went ahead and open a more general bug here so it can be triage more properly and it also means it's a public issue now that you can follow if you want to.

    Side note: It's not visible for the public, but this forum post thread is linked to this bug internally, so it's already clear it comes from you and it's also clear how Sequences increase the appearance of this bug. I'm mostly saying that so that you know you don't necessarily have to "vote on the issue".

    Thanks for your patience as always!
     
    akent99 likes this.
  7. ellka

    ellka

    Unity Technologies

    Joined:
    Jun 17, 2019
    Posts:
    71
    Hey @akent99, the bug linked in the post above should be fixed now!

    It ended up being fixed in the Timeline package, the new versions to use are either 1.6.3 or 1.5.7.

    I can say for sure that 1.6.3 is available (and discoverable) in Unity 2022.1. If it is not the case in the Unity version you are using, you can manually update your project manifest.json with 1.6.3 (or 1.5.7, but I think you're more up to date than that if my memory is good) and you should be good to go!

    Let us know if all is good for you! Thanks
     
  8. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    588
    Thank you for the update. Unfortunately it looks like case 1367857 is not fixed yet (a different rigging animation with sequences problem), so overall rigging animation is still not reliable for me (stack traces in the console).
     

    Attached Files:

  9. thomastt_unity

    thomastt_unity

    Unity Technologies

    Joined:
    Nov 6, 2018
    Posts:
    12
    @akent99, I've forwarded your case to the Animation Rigging dev team. Someone will have a look at it. Thank you as always for your various reports and feedback.
     
  10. ellka

    ellka

    Unity Technologies

    Joined:
    Jun 17, 2019
    Posts:
    71
    Hey @akent99, indeed, only this one is fixed for now. If you could confirm that at least that works on your side it's already something!

    I see that 1367857 is already assigned to someone though, I think the pushing from Thomas worked well! I believe that the fact it doesn't happen "all the time" makes it harder to fix. We'll keep you updated on that!
     
  11. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    588
    When I get some time I will try to repeat the setup I had at the time. I am not using Sequence Assembly and prefabs like that any more, so I will have to create a custom project to try and repeat. I tried to repeat when I upgraded, but I cannot be sure the other problem was masking this issue or not.
     
  12. ellka

    ellka

    Unity Technologies

    Joined:
    Jun 17, 2019
    Posts:
    71
    Ah yes true! I forgot about your custom Sequence Assembly! If it's not a problem you face anymore, no need to check if it's fixed, it was already checked internally before releasing hopefully :p.

    I just wanted to make sure that on the two issues you mention at least one was not blocking you anymore... which seems to be the case, even if it's not thanks to the fix ^^.
     
  13. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    588
    Just an update with Unity 2022.1.0b4.2571, Cinematic Studio, and 3D Characters and Animation (so loads Animation Rigging 1.1.1 and Sequences 1.1.0-pre.1 and Timeline 1.7.0-pre.1) still fails to support Animation Rigging with Sequences. So you cannot use an animation clip, but override a hand position (e.g. holding a door knob or picking up a coin etc - the purpose of Animation Rigging) with Cinematic Studio.

    Code (csharp):
    1.  
    2. NullReferenceException: Object reference not set to an instance of an object
    3. UnityEngine.Animations.Rigging.RigBuilder.UpdatePreviewGraph (UnityEngine.Playables.PlayableGraph graph) (at Library/PackageCache/com.unity.animation.rigging@1.1.1/Runtime/AnimationRig/RigBuilder.cs:178)
    4. UnityEngine.Timeline.AnimationPreviewUpdateCallback.Evaluate () (at Library/PackageCache/com.unity.timeline@1.7.0-pre.1/Runtime/Animation/AnimationPreviewUpdateCallback.cs:40)
    5. UnityEngine.Timeline.TimelinePlayable.Evaluate (UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData frameData) (at Library/PackageCache/com.unity.timeline@1.7.0-pre.1/Runtime/TimelinePlayable.cs:288)
    6. UnityEngine.Timeline.TimelinePlayable.PrepareFrame (UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info) (at Library/PackageCache/com.unity.timeline@1.7.0-pre.1/Runtime/TimelinePlayable.cs:249)
    7. UnityEngine.Timeline.DirectorControlPlayable:ProcessFrame(Playable, FrameData, Object) (at Library/PackageCache/com.unity.timeline@1.7.0-pre.1/Runtime/Playables/DirectorControlPlayable.cs:126)
    8.  
     
  14. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    588
    Hmmmm. Interesting. I exited and restarted the project and it started working... I then repeated the steps without watching the console closely, and the above error came up again. I deleted it all, started again, and got no errors in the console (works perfectly). There are about 20 steps, so I probably did them in a different order. But some ordering and it now works fine in 2022.1b4. Other ordering of actions comes up with errors (that seem to go away with a restart of Unity). Will try to come up with a repeatable failure flow. But it does work sometimes (which is GREAT news!).
     
  15. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    588
    Steps I took:
    • Create master sequence
    • Create nested sequence under master ("Shot 1")
    • Dragged character prefab directly under "Shot 1"
    • Dragged character into timeline and selected "Add Animation Track"
    • Dragged "Jump" animation clip into timeline.
    • Added override track (for recording animation rigging movements in)
    • (My prefab has the Rig Builder component disabled by default, and Rig Setup child nodes also disabled, and all weights set to zero.)
    • I enable Rig Builder component on parent.
    • I enabled Rig Setup child node. (The weights are all still set to zero, and I have not moved any target handles)
    • I scrub through the timeline and get lots of errors in the console (null reference)
    • I save and exit unity
    • I start up Unity.
    • No more errors in the console! I can scrub, set rigging weights, move the target handles, record, everything fine!
    Next experiment.
    • Similar to above, but I use "Unpack Completely" on the character prefab in the scene before enabling the rigging stuff.
    • Everything works without error.
    That gives me a potential workaround of restarting Unity when I see those errors. I have only tried it on a test project. Next, I will try on a copy of a real project.
     
  16. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    588
    Hmm. Copied a "real" project, and upgraded it to 2022.1b4. Sharing in case useful.
    • It looks like it re-ran the import script for VRM files during the upgrade. All my character prefabs were reset (all my customizations were wiped out). I had to copy the prefabs back from the original project after the upgrade to recover the project. (All the Timelines broke because my extra components were lost.)
      • UPDATE: I think this is because I copied the project, so the last modified time of the file triggered a "reimport".
    • All scenes are being enabled by default (not just the current one) making it run super super slow. Takes me like a minute or two to pick a sequence (click to expand master sequence in scene, wait a minute, click to expand next nested sequence, wait a minute), give it focus, so all the other sequence contents disappear. (Once it does get focus, things speed back up to normal)
      • UPDATE: I recall now being told "turn off all the sequences by default"
    • The NullReferenceException is not being fixed by a restart
    • I did an "Unpack all" on the prefab in the sequence, saved, restarted, 5 minutes later - still has NullRefernceExceoptions for the Animation Rigging. So on real project, not fixed.
    Code (csharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. UnityEngine.Animations.Rigging.RigBuilder.UpdatePreviewGraph (UnityEngine.Playables.PlayableGraph graph) (at Library/PackageCache/com.unity.animation.rigging@1.1.1/Runtime/AnimationRig/RigBuilder.cs:178)
    3. UnityEngine.Timeline.AnimationPreviewUpdateCallback.Evaluate () (at Library/PackageCache/com.unity.timeline@1.7.0-pre.1/Runtime/Animation/AnimationPreviewUpdateCallback.cs:40)
    4. UnityEngine.Timeline.TimelinePlayable.Evaluate (UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData frameData) (at Library/PackageCache/com.unity.timeline@1.7.0-pre.1/Runtime/TimelinePlayable.cs:288)
    5. UnityEngine.Timeline.TimelinePlayable.PrepareFrame (UnityEngine.Playables.Playable playable, UnityEngine.Playables.FrameData info) (at Library/PackageCache/com.unity.timeline@1.7.0-pre.1/Runtime/TimelinePlayable.cs:249)
    6. UnityEngine.Timeline.DirectorControlPlayable:ProcessFrame(Playable, FrameData, Object) (at Library/PackageCache/com.unity.timeline@1.7.0-pre.1/Runtime/Playables/DirectorControlPlayable.cs:126)
    (Example of when I open Unity - characters from multiple sequences (and lighting) all visible at once, washing out scene, and slowing down Unity to a crawl.)
    upload_2022-2-2_2-12-24.png

    After managing to focus on a squence, things speed up and go back to "normal". (But Animation Rigging not working.)
    upload_2022-2-2_2-18-1.png
     
    Last edited: Feb 3, 2022
  17. ellka

    ellka

    Unity Technologies

    Joined:
    Jun 17, 2019
    Posts:
    71
    I just checked the status of the two bugs you opened related to Animation Rigging + Sequences not working:
    • one was fixed in Timeline (released in 1.6.3 and backported in 1.5.7)
    • the other one looks like is fixed in the Animation Rigging package but not yet released
    I don't know if the second fix will help you...
    If what you're describing feels like it might be a third bug, don't hesitate to open a new bug from the Editor, especially with all those details.
    Or you can also comment on the second bug if it's related, it could help QA to ensure it fixes your issue as you wish (as it could gave them an other test project to verify the fix on).
     
  18. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    588
    It feels like the same as before, so that second bug may still be it. I will wait until it is released and give it another go there. Also (after sleep) I realized I need to disable all the sequences in the scene (a previous thread from you). I will give that a go too when the animation rigging bug fix out. That is the sort of fix worth upgrading for - it was so nice using it in the small project.
     
    ellka likes this.
  19. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    588
    Hi, just wondering if any news on when the Animation Rigging package with the bug fix is likely to come out?
     
  20. ellka

    ellka

    Unity Technologies

    Joined:
    Jun 17, 2019
    Posts:
    71
    I asked internally, it shouldn't be too long before Anim Rigging 1.2.0 is released! I can't say a number for sure... But it shouldn't be much more than a few days.
     
  21. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    588
    Thank you! The programmer in me translated "a few days" into "a few weeks", but that is good news for me either way! I was planning to do some more videos on "here is how I create a video using Sequences etc", but was partly waiting for a good version to do them with. Animation Rigging makes so much sense as part of the story.
     
    ellka likes this.