Search Unity

Playable Graph Evaluation Order

Discussion in 'Timeline' started by tree_fiddler_2000, Apr 9, 2019.

  1. tree_fiddler_2000

    tree_fiddler_2000

    Joined:
    Dec 5, 2018
    Posts:
    15
    I have a Timeline which is executing a Playable Graph. Some of the playables on my custom clips in this Timeline's Playable Graph (call it A) indirectly end up controlling playables in a separate Playable Graph (call it B).

    Right now, I have to buffer any changes which are triggered during ProcessFrame() for Graph A, such as requiring Play()ing graph B, until a LateUpdate(), otherwise I get crashes in the Editor. I assume these crashes are because Playable Graph's A &B are being executed simultaneously on worker threads during the Internal Animation Update, leading to badness.

    Is there I can set up an order of executing for two Play Graphs? So that A will be executed before B, and I can modify B from A's Process Frame directly? Or is there another, better way to fix this?

    Cheers,
     
  2. seant_unity

    seant_unity

    Unity Technologies

    Joined:
    Aug 25, 2015
    Posts:
    1,516
    There is no way to order execution of separate PlayableGraphs, and calling a separate graph to do something in a ProcessFrame() can be potentially dangerous. We have mechanisms in place to avoid cyclic-behaviour (e.g. graphA calling graphB calling graphA), but it seems like we missed a case.

    All C# calls to the playable system, like ProcessFrame(), are done on the main thread, so the crash you are getting is a concern. I'd recommend filing a bug with a repro case if possible.

    As for a better way, I think you are already on the right track. The graphs should queue behaviour to a monobehaviour LateUpdate(), where you can guarantee the order of operations as needed.
     
  3. tree_fiddler_2000

    tree_fiddler_2000

    Joined:
    Dec 5, 2018
    Posts:
    15
    Thanks, I've filed a bug report via the crash reporter.

    In my case, its not a cycle (Graph A triggers changes in Graph B, bot not vice versa). In the debugger, VS tells me the calls to Process Frame are made from a Worker Thread, but maybe that's misleading, and the main thread is labelled as a Worker Thread too.

    It would be great to get some log errors if the programmer does something wrong, like modifying graph B from graph A.
     
    seant_unity likes this.