Errors trying to restore blackboard variables (using object pooling)

NodeCanvas Forums Support Errors trying to restore blackboard variables (using object pooling)

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #16266
    ccfoo242
    Participant

    [Edit – i hate this editor]

    I’m trying to use Unity’s object pool. I was having weird results and I read in a post (not sure if here or on the Unity forum) that I must serialize the blackboard on creation then deserialize that on subsequent uses from the pool.

    First time after being created:

    1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]”

    },

    “deleteYourself”: {

    “_propertyPath”: “GamePiece.DeleteYourself”,

    “_name”: “deleteYourself”,

    “_id”: “9090a6ff-8d2c-466c-a1d5-770c7aecc0de”,

    “$type”: “NodeCanvas.Framework.Variable1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]”

    }

    }

    }

     

    Object is used then released back to the pool

    Next time it is pulled from the pool:

    1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]”

    },

    “deleteYourself”: {

    “_propertyPath”: “GamePiece.DeleteYourself”,

    “_name”: “deleteYourself”,

    “_id”: “9090a6ff-8d2c-466c-a1d5-770c7aecc0de”,

    “$type”: “NodeCanvas.Framework.Variable1[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]”

    }

    }

    }

     

    Results in these 3 errors:

     

    1<UnityEngine.Object>,bool) (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Variables/Blackboard.cs:102)

    GridElement:OnEnable () (at Assets/Scripts/GridElements/GridElement.cs:124)

    GridElement:Setup (GridElementTemplate,ElementLocation,UnityEngine.Vector3) (at Assets/Scripts/GridElements/GridElement.cs:181)

    GridManager:CreateNewGamePiece (int,int,MatchType,string,bool) (at Assets/Scripts/GridManager/GridManager.cs:363)

    GridManager:CreateNewGamePiece (int,int,Match,bool) (at Assets/Scripts/GridManager/GridManager.cs:326)

    GridManager:FillEmpties () (at Assets/Scripts/GridManager/GridManager.cs:819)

    NodeCanvas.Tasks.Actions.MainLoopInitTask:OnExecute () (at Assets/Scripts/NodeCanvasTasks/MainLoopInitTask.cs:18)

    NodeCanvas.Framework.ActionTask:Execute (UnityEngine.Component,NodeCanvas.Framework.IBlackboard) (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Tasks/ActionTask.cs:93)

    NodeCanvas.Framework.ActionList:OnUpdate () (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Tasks/ActionList.cs:101)

    NodeCanvas.Framework.ActionTask:Execute (UnityEngine.Component,NodeCanvas.Framework.IBlackboard) (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Tasks/ActionTask.cs:95)

    NodeCanvas.StateMachines.ActionState:OnUpdate () (at Assets/Imported/ParadoxNotion/NodeCanvas/Modules/StateMachines/Nodes/ActionState.cs:44)

    NodeCanvas.StateMachines.ActionState:OnEnter () (at Assets/Imported/ParadoxNotion/NodeCanvas/Modules/StateMachines/Nodes/ActionState.cs:41)

    NodeCanvas.StateMachines.FSMState:OnExecute (UnityEngine.Component,NodeCanvas.Framework.IBlackboard) (at Assets/Imported/ParadoxNotion/NodeCanvas/Modules/StateMachines/FSMState.cs:88)

    NodeCanvas.Framework.Node:Execute (UnityEngine.Component,NodeCanvas.Framework.IBlackboard) (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Graphs/Node.cs:297)

    NodeCanvas.StateMachines.FSM:EnterState (NodeCanvas.StateMachines.FSMState,NodeCanvas.StateMachines.FSM/TransitionCallMode) (at Assets/Imported/ParadoxNotion/NodeCanvas/Modules/StateMachines/FSM.cs:171)

    NodeCanvas.StateMachines.FSM:OnGraphUpdate () (at Assets/Imported/ParadoxNotion/NodeCanvas/Modules/StateMachines/FSM.cs:80)

    NodeCanvas.Framework.Graph:UpdateGraph (single) (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Graphs/Graph.cs:684)

    NodeCanvas.Framework.Graph:UpdateGraph () (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Graphs/Graph.cs:677)

    ParadoxNotion.Services.MonoManager:Update () (at Assets/Imported/ParadoxNotion/CanvasCore/Common/Runtime/Services/MonoManager.cs:98)

    <pre><code>(Blackboard Error): Can't cast value 'False' to blackboard variable of name 'deleteYourself' and type 'Boolean'

    UnityEngine.Logger:Log (UnityEngine.LogType,string,object,UnityEngine.Object)

    ParadoxNotion.Services.Logger:ForwardToUnity (UnityEngine.LogType,object,string,object) (at Assets/Imported/ParadoxNotion/CanvasCore/Common/Runtime/Services/Logger.cs:116)

    ParadoxNotion.Services.Logger:Internal_Log (UnityEngine.LogType,object,string,object) (at Assets/Imported/ParadoxNotion/CanvasCore/Common/Runtime/Services/Logger.cs:108)

    ParadoxNotion.Services.Logger:LogError (object,string,object) (at Assets/Imported/ParadoxNotion/CanvasCore/Common/Runtime/Services/Logger.cs:61)

    NodeCanvas.Framework.IBlackboardExtensions:SetVariableValue (NodeCanvas.Framework.IBlackboard,string,object) (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Variables/IBlackboardExtensions.cs:133)

    NodeCanvas.Framework.IBlackboardExtensions:OverwriteFrom (NodeCanvas.Framework.IBlackboard,NodeCanvas.Framework.IBlackboard,bool) (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Variables/IBlackboardExtensions.cs:227)

    NodeCanvas.Framework.Blackboard:Deserialize (string,System.Collections.Generic.List</code></pre>
    1<UnityEngine.Object>,bool) (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Variables/Blackboard.cs:102)

    GridElement:OnEnable () (at Assets/Scripts/GridElements/GridElement.cs:124)

    GridElement:Setup (GridElementTemplate,ElementLocation,UnityEngine.Vector3) (at Assets/Scripts/GridElements/GridElement.cs:181)

    GridManager:CreateNewGamePiece (int,int,MatchType,string,bool) (at Assets/Scripts/GridManager/GridManager.cs:363)

    GridManager:CreateNewGamePiece (int,int,Match,bool) (at Assets/Scripts/GridManager/GridManager.cs:326)

    GridManager:FillEmpties () (at Assets/Scripts/GridManager/GridManager.cs:819)

    NodeCanvas.Tasks.Actions.MainLoopInitTask:OnExecute () (at Assets/Scripts/NodeCanvasTasks/MainLoopInitTask.cs:18)

    NodeCanvas.Framework.ActionTask:Execute (UnityEngine.Component,NodeCanvas.Framework.IBlackboard) (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Tasks/ActionTask.cs:93)

    NodeCanvas.Framework.ActionList:OnUpdate () (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Tasks/ActionList.cs:101)

    NodeCanvas.Framework.ActionTask:Execute (UnityEngine.Component,NodeCanvas.Framework.IBlackboard) (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Tasks/ActionTask.cs:95)

    NodeCanvas.StateMachines.ActionState:OnUpdate () (at Assets/Imported/ParadoxNotion/NodeCanvas/Modules/StateMachines/Nodes/ActionState.cs:44)

    NodeCanvas.StateMachines.ActionState:OnEnter () (at Assets/Imported/ParadoxNotion/NodeCanvas/Modules/StateMachines/Nodes/ActionState.cs:41)

    NodeCanvas.StateMachines.FSMState:OnExecute (UnityEngine.Component,NodeCanvas.Framework.IBlackboard) (at Assets/Imported/ParadoxNotion/NodeCanvas/Modules/StateMachines/FSMState.cs:88)

    NodeCanvas.Framework.Node:Execute (UnityEngine.Component,NodeCanvas.Framework.IBlackboard) (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Graphs/Node.cs:297)

    NodeCanvas.StateMachines.FSM:EnterState (NodeCanvas.StateMachines.FSMState,NodeCanvas.StateMachines.FSM/TransitionCallMode) (at Assets/Imported/ParadoxNotion/NodeCanvas/Modules/StateMachines/FSM.cs:171)

    NodeCanvas.StateMachines.FSM:OnGraphUpdate () (at Assets/Imported/ParadoxNotion/NodeCanvas/Modules/StateMachines/FSM.cs:80)

    NodeCanvas.Framework.Graph:UpdateGraph (single) (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Graphs/Graph.cs:684)

    NodeCanvas.Framework.Graph:UpdateGraph () (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Graphs/Graph.cs:677)

    ParadoxNotion.Services.MonoManager:Update () (at Assets/Imported/ParadoxNotion/CanvasCore/Common/Runtime/Services/MonoManager.cs:98)

    And

    1+<>c__DisplayClass27_3[T].<InitializePropertyBinding>b__5 (T o) (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Variables/Variable.cs:280)

    NodeCanvas.Framework.Variable1[T].InitializePropertyBinding (UnityEngine.GameObject go, System.Boolean callSetter) (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Variables/Variable.cs:281)

    NodeCanvas.Framework.IBlackboardExtensions.InitializePropertiesBinding (NodeCanvas.Framework.IBlackboard blackboard, UnityEngine.Component target, System.Boolean callSetter) (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Variables/IBlackboardExtensions.cs:146)

    NodeCanvas.Framework.Blackboard.Deserialize (System.String json, System.Collections.Generic.List1[T] references, System.Boolean removeMissingVariables) (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Variables/Blackboard.cs:103)

    GridElement.OnEnable () (at Assets/Scripts/GridElements/GridElement.cs:124)

    UnityEngine.GameObject:SetActive(GameObject, Boolean)

    GridElement:Setup(GridElementTemplate, ElementLocation, Vector3) (at Assets/Scripts/GridElements/GridElement.cs:181)

    GridManager:CreateNewGamePiece(Int32, Int32, MatchType, String, Boolean) (at Assets/Scripts/GridManager/GridManager.cs:363)

    GridManager:CreateNewGamePiece(Int32, Int32, Match, Boolean) (at Assets/Scripts/GridManager/GridManager.cs:326)

    GridManager:FillEmpties() (at Assets/Scripts/GridManager/GridManager.cs:819)

    NodeCanvas.Tasks.Actions.MainLoopInitTask:OnExecute() (at Assets/Scripts/NodeCanvasTasks/MainLoopInitTask.cs:18)

    NodeCanvas.Framework.ActionTask:Execute(Component, IBlackboard) (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Tasks/ActionTask.cs:93)

    NodeCanvas.Framework.ActionList:OnUpdate() (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Tasks/ActionList.cs:101)

    NodeCanvas.Framework.ActionTask:Execute(Component, IBlackboard) (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Tasks/ActionTask.cs:95)

    NodeCanvas.StateMachines.ActionState:OnUpdate() (at Assets/Imported/ParadoxNotion/NodeCanvas/Modules/StateMachines/Nodes/ActionState.cs:44)

    NodeCanvas.StateMachines.ActionState:OnEnter() (at Assets/Imported/ParadoxNotion/NodeCanvas/Modules/StateMachines/Nodes/ActionState.cs:41)

    NodeCanvas.StateMachines.FSMState:OnExecute(Component, IBlackboard) (at Assets/Imported/ParadoxNotion/NodeCanvas/Modules/StateMachines/FSMState.cs:88)

    NodeCanvas.Framework.Node:Execute(Component, IBlackboard) (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Graphs/Node.cs:297)

    NodeCanvas.StateMachines.FSM:EnterState(FSMState, TransitionCallMode) (at Assets/Imported/ParadoxNotion/NodeCanvas/Modules/StateMachines/FSM.cs:171)

    NodeCanvas.StateMachines.FSM:OnGraphUpdate() (at Assets/Imported/ParadoxNotion/NodeCanvas/Modules/StateMachines/FSM.cs:80)

    NodeCanvas.Framework.Graph:UpdateGraph(Single) (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Graphs/Graph.cs:684)

    NodeCanvas.Framework.Graph:UpdateGraph() (at Assets/Imported/ParadoxNotion/CanvasCore/Framework/Runtime/Graphs/Graph.cs:677)

    ParadoxNotion.Services.MonoManager:Update() (at Assets/Imported/ParadoxNotion/CanvasCore/Common/Runtime/Services/MonoManager.cs:98)`
     

    Here’s my code in OnEnable():

    Any idea what I’m doing wrong?

    #16267
    ccfoo242
    Participant

    Stepping through with the debugger, setMethod is null here (Variable.cs) line 280:

    if ( prop.CanWrite ) {
    try { setter = setMethod.RTCreateDelegate<Action<T>>(instance); } //JIT
    catch { setter = (o) => { setMethod.Invoke(instance, ReflectionTools.SingleTempArgsArray(o)); }; } //AOT
    if ( callSetter ) { setter(_value); }
    } else {
    setter = (o) => { Logger.LogError(string.Format(“You tried to Set a Property Bound Variable ‘{0}’, but the Bound Property ‘{1}’ is Read Only!”, name, _propertyPath), LogTag.VARIABLE, go); };
    }

    #16268
    ccfoo242
    Participant

    *SMACKS FOREHEAD*

    These are readonly properties.

    Perhaps a null check on setMethod before trying to use it is in order?

    #16282
    Gavalakis
    Keymaster

    Hey,

    Oh I see. The setMethod is in a try/catch block and the .CanWrite property is already checked, so I omitted to check the setMethod for null, but sure I will better add a null check anyways. Thanks.

    Join us on Discord: https://discord.gg/97q2Rjh

    #16540
    Andy Miira
    Participant

    Do you have any ETA on when this Variable.cs setMethod null check will be added?
    I’m having null reference exceptions because of this same issue, on NodeCanvas v3.2.5.

    #16555
    Andy Miira
    Participant

    Actually, in my case, the setMethod null reference exception still helped me locate an error in my logic.
    I was trying to set a property bound variable that had the following getter/setter:

    In this case, I had to remove the “protected” keyword, for NodeCanvas to be able to set the variable correctly.

    I still think a null check and extra LogError for that setMethod inside the catch {} block would be helpful, to hint to the user about potential cases like mine above.

    #16564
    Gavalakis
    Keymaster

    Hello,

    Hmm. The setMethod is checked for null for some time now. It may be that you are using an older version? :).

    Thanks!

    Join us on Discord: https://discord.gg/97q2Rjh

    #16568
    Andy Miira
    Participant

    Hello, Hmm. The setMethod is checked for null for some time now. It may be that you are using an older version? :). Thanks!

    I don’t think that’s the case at all, both regarding setMethod being checked for null, and me using an older version of Node Canvas.
    As mentioned in a few posts above, I’m using NodeCanvas v3.2.5, the latest version available on Asset Store.

    Stepping through with the debugger, setMethod is null here (Variable.cs) line 280: if ( prop.CanWrite ) {
    try { setter = setMethod.RTCreateDelegate<Action<T>>(instance); } //JIT
    catch { setter = (o) => { setMethod.Invoke(instance, ReflectionTools.SingleTempArgsArray(o)); }; } //AOT
    if ( callSetter ) { setter(_value); }
    } else {
    setter = (o) => { Logger.LogError(string.Format(“You tried to Set a Property Bound Variable ‘{0}’, but the Bound Property ‘{1}’ is Read Only!”, name, _propertyPath), LogTag.VARIABLE, go); };
    }

    I’m having this exact issue reported by ccfoo242 (setMethod being null in line 280 from Variable.cs), in specific cases like the one from my post above (trying to set a property-bound variable that had “protected set”).

    #16569
    Andy Miira
    Participant

    Hello, Hmm. The setMethod is checked for null for some time now. It may be that you are using an older version? :). Thanks!

    Actually, you’re right, I was using an older version.
    I just updated Node Canvas in my project (via Package Manager), and there were code updates, including the setMethod null check.

    The odd thing is that, based on my project’s version control, I had updated Node Canvas to v3.2.5 circa July 2022.
    But the latest version on the Asset Store (from August 29, 2022) is also numbered v3.2.5? That’s what made me confused earlier.

    Anyway, thanks for giving me the hint to upgrade Node Canvas. 😀

    #16606
    Gavalakis
    Keymaster

    Hey, sorry for the late reply!

    Yes indeed, I’ve made a few very minor changes/fixes but kept the same version number for 3.2.5 on a few occasions. 🙂

    Thanks!

    Join us on Discord: https://discord.gg/97q2Rjh

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