Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Bug Animator Crash when using PlayableGraph

Discussion in 'Animation' started by future_star, Apr 15, 2024.

  1. future_star

    future_star

    Joined:
    Jul 7, 2021
    Posts:
    2
    I've been encountering a consistent crash issue when using PlayableGraph to control animations in my character. After extensive testing, I've managed to reproduce the crash consistently. Here is the test code that demonstrates the problem:

    Code (CSharp):
    1. public class CrashLaunch : MonoBehaviour
    2. {
    3.     public Animator Animator;
    4.     public RuntimeAnimatorController AnimatorController;
    5.  
    6.     private PlayableGraph mGraph;
    7.     private AnimationMixerPlayable mMixer;
    8.  
    9.     private void Awake()
    10.     {
    11.         DoCrash();
    12.     }
    13.  
    14.     private void OnDestroy()
    15.     {
    16.         if (mGraph.IsValid())
    17.         {
    18.             mGraph.Destroy();
    19.         }
    20.     }
    21.  
    22.     private void DoCrash()
    23.     {
    24.         mGraph = PlayableGraph.Create("CrashGraph");
    25.         mGraph.SetTimeUpdateMode(DirectorUpdateMode.Manual);
    26.         mMixer = AnimationMixerPlayable.Create(mGraph);
    27.         var output = AnimationPlayableOutput.Create(mGraph, "output", Animator);
    28.         output.SetSourcePlayable(mMixer);
    29.  
    30.         SetRuntimeAnimationController(Animator.runtimeAnimatorController);
    31.         Animator.runtimeAnimatorController = null;
    32.         SetRuntimeAnimationController(AnimatorController);
    33.  
    34.         mGraph.Play();
    35.  
    36.         Animator.SetFloat("CrashTrigger", 1);
    37.     }
    38.  
    39.     private void SetRuntimeAnimationController(RuntimeAnimatorController controller)
    40.     {
    41.         var animatorPlayable = AnimatorControllerPlayable.Create(mGraph, controller);
    42.  
    43.         if (mMixer.GetInputCount() > 0)
    44.         {
    45.             Playable playable = mMixer.GetInput(0);
    46.             mMixer.DisconnectInput(0);
    47.             playable.Destroy();
    48.             mMixer.ConnectInput(0, animatorPlayable, 0);
    49.         }
    50.         else
    51.         {
    52.             mMixer.AddInput(animatorPlayable, 0, 1);
    53.         }
    54.     }
    55. }
    The crash log shows the following call stack:
    Code (CSharp):
    1.  Managed Stacktrace:
    2. =================================================================
    3.    at <unknown> <0xffffffff>
    4.    at UnityEngine.Animator:SetFloatString <0x00168>
    5.    at UnityEngine.Animator:SetFloat <0x000a2>
    6.    at CrashLaunch:DoCrash <0x0055a>
    7.    at CrashLaunch:Awake <0x00082>
    8.    at System.Object:runtime_invoke_void__this__ <0x00187>
    9. ===============================================================
    10. Received signal SIGSEGV
    11. Obtained 33 stack frames
    12. 0x00007ff740b24a15 (Unity) Animator_CUSTOM_SetFloatString
    13. 0x00000203ffff7c89 (Mono JIT Code) (wrapper managed-to-native) UnityEngine.Animator:SetFloatString (UnityEngine.Animator,string,single)
    14. 0x00000203ffff7a83 (Mono JIT Code) UnityEngine.Animator:SetFloat (string,single)
    15. 0x00000203fffebe2b (Mono JIT Code) CrashLaunch:DoCrash () (at D:/UnityWorkspace/PlayableGraphCrash/Assets/CrashLaunch.cs:37)
    16. 0x00000203fffeb853 (Mono JIT Code) CrashLaunch:Awake () (at D:/UnityWorkspace/PlayableGraphCrash/Assets/CrashLaunch.cs:18)
    17. 0x0000020219ab3c58 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
    18. 0x00007ff88b694bfe (mono-2.0-bdwgc) mono_jit_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/mini/mini-runtime.c:3445)
    19. 0x00007ff88b5cd254 (mono-2.0-bdwgc) do_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3068)
    20. 0x00007ff88b5cd3cc (mono-2.0-bdwgc) mono_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3115)
    21. 0x00007ff7418af514 (Unity) scripting_method_invoke
    22. 0x00007ff74188d274 (Unity) ScriptingInvocation::Invoke
    23. 0x00007ff74188d35e (Unity) ScriptingInvocation::InvokeChecked
    24. 0x00007ff74192fc26 (Unity) SerializableManagedRef::CallMethod
    25. 0x00007ff7418748fb (Unity) MonoBehaviour::CallAwake
    26. 0x00007ff741872d95 (Unity) MonoBehaviour::AddToManager
    27. 0x00007ff741873ada (Unity) MonoBehaviour::AwakeFromLoad
    28. 0x00007ff741971e0d (Unity) AwakeFromLoadQueue::InvokePersistentManagerAwake
    29. 0x00007ff741972de1 (Unity) AwakeFromLoadQueue::PersistentManagerSingleQueueAwakeFromLoad
    30. 0x00007ff741972a50 (Unity) AwakeFromLoadQueue::PersistentManagerAwakeFromLoad_NoChecks
    31. 0x00007ff74156e825 (Unity) LoadSceneOperation::CompleteAwakeSequence
    32. 0x00007ff74156f3a0 (Unity) LoadSceneOperation::CompletePreloadManagerLoadSceneEditor
    33. 0x00007ff74157008e (Unity) LoadSceneOperation::IntegrateMainThread
    34. 0x00007ff7415736ae (Unity) PreloadManager::UpdatePreloadingSingleStep
    35. 0x00007ff741573dcf (Unity) PreloadManager::WaitForAllAsyncOperationsToComplete
    36. 0x00007ff7427f0a72 (Unity) EditorSceneManager::RestoreSceneBackups
    37. 0x00007ff7424eb4f6 (Unity) PlayerLoopController::EnterPlayMode
    38. 0x00007ff7424fbcb6 (Unity) PlayerLoopController::SetIsPlaying
    39. 0x00007ff7424ff3b0 (Unity) Application::TickTimer
    40. 0x00007ff74297977a (Unity) MainMessageLoop
    41. 0x00007ff74297e650 (Unity) WinMain
    42. 0x00007ff743d5e0ae (Unity) __scrt_common_main_seh
    43. 0x00007ff8fb777344 (KERNEL32) BaseThreadInitThunk
    44. 0x00007ff8fc3626b1 (ntdll) RtlUserThreadStart
    The submitted attachment is a project that crashes when the SampleScene is run.
     

    Attached Files:

  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,597
    Report a bug via the Help menu.
     
  3. future_star

    future_star

    Joined:
    Jul 7, 2021
    Posts:
    2
    Thanks, I have already reported.