PlayableGraph Evaluate performance/best practices

1. I’ve read calling Update manually on an Animator " means your animators will run single-threaded ". How much of the cost of an Animator update comes from the graph evaluation? Is calling Evaluate on a playable graph with Animation Outputs essentially equally expensive?

Yes - Update() (or PlayableDirector.Evaluate()) evaluates the entire graph single threaded, and that is where most of the cost is. An animator controller is a playable graph, as is timeline and the evaluate does a prepare (updates the graphs links and weights) and a Process (actually evaluation of the animation data).

2. When dealing with a Timeline graph that has both script and animation outputs, are the animation outputs evaluated at a different point during the update cycle? Is that work threaded during the internal animation update? Just the ProcessFrame part?

Yes - the entire graph in that case is ‘Prepared’ single threaded, but the Process step of the animation is threaded. The ProcessFrame of the script playables is run on the main thread.

3. Related to #2; when overriding the outputs on a custom TrackAsset to have AnimationPlayableBindings, is the resulting Animation Output updated and processed in the same way as default Animation Track outputs? Does this have any impact on the PrepareData phase of a custom playable connected to this branch?

Yes - is is processed the same. PrepareData/PrepareFrame happen single threaded for all of timeline.

4. And more generally; Are any of the PrepareData, PrepareFrame and ProcessFrame phases ever run outside of Evaluate? The documentation on why these particular phases exist (or what happens inbetween them) is quite brief.

If by Evaluate() you mean PlayableDirector.Evaluate() or PlayableGraph.Evaluate(), then no. Those are intended to be synchronous evaluations of a graph. When a graph is playing however, Evaluate() isn’t called. Those phases are split up and run at different points in the PlayerLoop (but all between Update() & LateUpdate()), and threaded as appropriate.

I hope that clarifies it a bit.

4 Likes