Graph.OnEnable() cost too much CPU time ! How to optimize this problem?

FlowCanvas Forums Support Graph.OnEnable() cost too much CPU time ! How to optimize this problem?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #3315

    this profile picture is attached!

    You must be logged in to view attached files.

    Hello there,

    It all depends on what you are doing on the Graph OnEnable node output. The node itself does not have any performance impact, but what you have connected on its output can have. Can you please post a screenshot of your graph nodes connected to your OnEnable node output?

    Thank you.

    Join us on Discord:


    Each gameObject is initialized, it will call StartGraph function, this function will access each flowcanvas node, if the number of node is large, then consume too much main CPU time!

    The CPU time cost here!
    ///<summary>Start the graph for the agent and blackboard provided with specified update mode. Optionally provide a callback for when the graph stops/ends</summary>
    public void StartGraph(Component newAgent, IBlackboard newParentBlackboard, UpdateMode newUpdateMode, System.Action<bool> callback = null) {

    Debug.Assert(Application.isPlaying, “StartGraph should have been called in play mode only.”);
    Debug.Assert(!UnityEditor.EditorUtility.IsPersistent(this), “You have tried to start a graph which is an asset, not an instance! You should Instantiate the graph first.”);

    Debug.Assert(newParentBlackboard != this.blackboard, “StartGraph called with blackboard parameter being the same as the graph blackboard”);

    if ( newAgent == null && requiresAgent ) {
    Logger.LogError(“You’ve tried to start a graph with null Agent.”, LogTag.GRAPH, this);

    if ( primeNode == null && requiresPrimeNode ) {
    Logger.LogError(“You’ve tried to start graph without a ‘Start’ node.”, LogTag.GRAPH, this);

    if ( isRunning && !isPaused ) {
    Logger.LogWarning(“Graph is already Active and not Paused.”, LogTag.GRAPH, this);

    if ( !hasInitialized ) {
    Initialize(newAgent, newParentBlackboard, false);
    } else {
    //if the graph has pre-initialized with same targets, this call does basically nothing,
    //but we still need to call it in case the graph is started with different targets.
    UpdateReferences(newAgent, newParentBlackboard);

    if ( callback != null ) { onFinish = callback; }

    if ( isRunning && isPaused ) {

    if ( _runningGraphs == null ) { _runningGraphs = new List<Graph>(); }
    elapsedTime = 0;

    isRunning = true;
    isPaused = false;


    for ( var i = 0; i < allNodes.Count; i++ ) {

    for ( var i = 0; i < allNodes.Count; i++ ) {

    updateMode = newUpdateMode;
    if ( updateMode != UpdateMode.Manual ) {
    MonoManager.current.AddUpdateCall((MonoManager.UpdateMode)updateMode, UpdateGraph);

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.