Search Unity

Animator.ProcessRootMotion even when not using root motion.

Discussion in 'Animation' started by GloriaVictis, Aug 16, 2019.

  1. GloriaVictis

    GloriaVictis

    Joined:
    Sep 1, 2016
    Posts:
    133
    Hello,

    We are using 2017.4.LTS version of Unity, our characters use Generic animator type and no root motion at all, the bool is set as false. Still tho, the profiler shows Animator.ProcessRootMotion with around 0.1ms per animator update - which, as many times we have 50+ character on screen significantly affect our FPS.

    Is it normal behaviour or we could evade it anyhow?
     
  2. GloriaVictis

    GloriaVictis

    Joined:
    Sep 1, 2016
    Posts:
    133
    Bump, can anyone confirm this is normal behaviour or how to evade that?
     
  3. GloriaVictis

    GloriaVictis

    Joined:
    Sep 1, 2016
    Posts:
    133
  4. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    yes this is expected, in 2018 this profiler tag has been renamed to Animators.ProcessGraphJob.

    Animator.ProcessRootMotion was a bad name for this step.

    this step is mandatory as it does evaluate the whole animation graph
     
  5. GloriaVictis

    GloriaVictis

    Joined:
    Sep 1, 2016
    Posts:
    133
    Okay, thank you
     
  6. TP-Fab

    TP-Fab

    Joined:
    Jul 10, 2019
    Posts:
    37
    Hi, resurrecting this thread as in 2020.3 I can still observe AnimationScriptPlayable.ProcessRootMotion in the profiler (despite ApplyRootMotion disabled), directly under Animator.ProcessGraph (itself included in Animators.ProcessGraphJob) . What's going on with this?
     
    zalogic likes this.
  7. JohnAustinPontoco

    JohnAustinPontoco

    Joined:
    Dec 23, 2013
    Posts:
    283
    Unity still runs the ProcessRootMotion function of IAnimationJobs, even if there is nothing to be done. None of the Animation Jobs in the AnimationRigging package actually use RootMotion, but Unity still schedules jobs for them!

    This means that if you have a lot of very lightweight rigs / AnimationScriptPlayables, Unity spends half of the animation time scheduling jobs that literally do nothing.

    :(

    See here, where it schedules the ProcessRootMotion jobs for MultiParentConstraintJob:
    upload_2022-5-4_22-14-49.png

    ... for which the definition is empty:

    Code (CSharp):
    1. /// <summary>
    2.         /// Defines what to do when processing the root motion.
    3.         /// </summary>
    4.         /// <param name="stream">The animation stream to work on.</param>
    5.         public void ProcessRootMotion(AnimationStream stream) { }
    6.  
     

    Attached Files:

  8. JohnAustinPontoco

    JohnAustinPontoco

    Joined:
    Dec 23, 2013
    Posts:
    283
    @Mecanim-Dev Is there any way to force these root motion jobs to be skipped? This is happening even with Animator.applyRootMotion set to false. Unity 2020.3.17f1
     
  9. JohnAustinPontoco

    JohnAustinPontoco

    Joined:
    Dec 23, 2013
    Posts:
    283
    You can see here how it's spending half of the animation time, just on running these empty jobs:

    upload_2022-5-4_22-18-7.png
     
    GloriaVictis likes this.
  10. WendelinReich

    WendelinReich

    Joined:
    Dec 22, 2011
    Posts:
    228
    Why not test this with 2021.3 LTS or even 2022?
     
  11. JohnAustinPontoco

    JohnAustinPontoco

    Joined:
    Dec 23, 2013
    Posts:
    283
    Just not worth the time, unless it seems like something that would be fixed. This seems like an intentional architecture decision, not a bug. Plus, we're stuck on 2020.3 for the time being.

    We solved this by writing our own animation logic in a custom job, and skipping the Animation Rigging package entirely. That made it 10-20x faster, haha.
     
  12. GloriaVictis

    GloriaVictis

    Joined:
    Sep 1, 2016
    Posts:
    133

    Sounds awesome! Even though of sharing the solution via asset store for example?
     
  13. JohnAustinPontoco

    JohnAustinPontoco

    Joined:
    Dec 23, 2013
    Posts:
    283
    GloriaVictis likes this.
  14. Mayumichi

    Mayumichi

    Joined:
    Mar 12, 2017
    Posts:
    31
    Just noticed this on 2022.2, it's a huge performance drain on useless processing if you're not utilizing any root motion. I can't just modify the animation package, or whatever is scheduling it, to get rid of this right? Makes me reconsider whether to use AnimationRigging if that's the cause :(
     
    VirtusH likes this.