- A* version:5.2.5
- Unity version: 6.0.23f1 OSX - apple chip
I am using a custom PointGraph and a custom pointNode. I add and remove nodes outside of scan but only inside AstarPath.active.AddWorkItem and I call AstarPath.active.FlushWorkItems() on the next line. I have tested in Editor and at runtime, called from an Odin button in the inspector.
I only destroy nodes by calling RemoveNode() on my custom PointGraph. I do not have RemoveNode() in my class and the call goes straight to PointNode.RemoveNode() which looks like it handles removing the node from Nodes. This seemed to work for a while until started doing more in a single execution. Now I always get this error in the same place. I added the node.position to the error message so I could track its removal and make sure where it happened.
InvaliOperationException: A node in a SkyPointGraph contained a connection to a destroyed SkywalkNode( 0, 13000, 4000).
Pathfindding.HierarchicalGraph+JobRecalculateComponents+<>c.b__12_0 (Pathfinding.GraphNode neighbour, Pathfinding.HierarchicalGraph+JobRecalculateComponents+Context& context) (at ./Packages/com.arongranberg.astar/Core/Pathfinding/HierarchicalGraph.cs:414)
Pathfinding.PointNode.GetConnections[T] (Pathfinding.GraphNode+GetConnectionsWithData`1[T] action, T& data, System.Int32 connectionFilter) (at ./Packages/com.arongranberg.astar/Graphs/Nodes/PointNode.cs:83)
Pathfinding.HierarchicalGraph+JobRecalculateComponents.FindHierarchicalNodeChildren (Pathfinding.HierarchicalGraph hGraph, System.Int32 hierarchicalNode, Pathfinding.GraphNode startNode) (at ./Packages/com.arongranberg.astar/Core/Pathfinding/HierarchicalGraph.cs:416)
Pathfinding.HierarchicalGraph+JobRecalculateComponents.Execute () (at ./Packages/com.arongranberg.astar/Core/Pathfinding/HierarchicalGraph.cs:511)
Unity.Jobs.IJobExtensions+JobStruct`1[T].Execute (T& data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at /Users/bokken/build/output/unity/unity/Runtime/Jobs/Managed/IJob.cs:61)
I can see from logs that Immediately after I delete the node in a workitem the error happens.
Is there something more I should be doing to make sure no other A* path jobs are run on other threads while I am running WorkItems. This all happens during level creation at runtime ( or in the editor for testing), so there will be no unexpected path searching or any calls from my code to A* Pathfinding.
Can I turn off these background jobs and manually call them in a workItem then flush them?
My log message from destroying the node just before the error ( long)
DestroyNode ( 0, 13000, 3000)
UnityEngine.Debug:Log (object)
SkyPointGraph:DestroyNode (SkywalkNode,bool) (at Assets/Tiles/Generation/Scripts/Skywalk/SkyPointGraph.cs:328)
SkywalkMakePaths2/<>c__DisplayClass30_0:b__0 () (at Assets/Tiles/Generation/Scripts/Skywalk/SkywalkMakePaths2.cs:209)
Pathfinding.WorkItemProcessor:ProcessWorkItems (bool,bool) (at ./Packages/com.arongranberg.astar/Core/Misc/WorkItemProcessor.cs:323)
Pathfinding.WorkItemProcessor:ProcessWorkItemsForUpdate (bool) (at ./Packages/com.arongranberg.astar/Core/Misc/WorkItemProcessor.cs:423)
AstarPath:PerformBlockingActions (bool) (at ./Packages/com.arongranberg.astar/Core/AstarPath.cs:875)
AstarPath:FlushWorkItems () (at ./Packages/com.arongranberg.astar/Core/AstarPath.cs:1131)
SkywalkMakePaths2:RemoveNodesConnectionBounds (UnityEngine.Bounds) (at Assets/Tiles/Generation/Scripts/Skywalk/SkywalkMakePaths2.cs:250)
SkywalkMakePaths2:RemoveGraphNodesConnections (BuildUnit) (at Assets/Tiles/Generation/Scripts/Skywalk/SkywalkMakePaths2.cs:169)
ShardGenerator:PlaceBuilding (ShardHolder,bool) (at Assets/Tiles/Generation/Scripts/Shard/ShardGenerator.cs:133)
ShardGenerator:PlaceTestBuildings () (at Assets/Tiles/Generation/Scripts/Shard/ShardGenerator.cs:97)
Generator2:TestFullGenerate () (at Assets/Tiles/Generation/Scripts/Shard/Generator2.cs:60)
System.Reflection.MethodBase:Invoke (object,object)
Sirenix.OdinInspector.Editor.Drawers.DefaultMethodDrawer:InvokeMethodInfo (System.Reflection.MethodInfo) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/DefaultMethodDrawer.cs:549)
Sirenix.OdinInspector.Editor.Drawers.DefaultMethodDrawer:InvokeButton () (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/DefaultMethodDrawer.cs:450)
Sirenix.OdinInspector.Editor.Drawers.DefaultMethodDrawer:DrawNormalButton () (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/DefaultMethodDrawer.cs:297)
Sirenix.OdinInspector.Editor.Drawers.DefaultMethodDrawer:DrawPropertyLayout (UnityEngine.GUIContent) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/DefaultMethodDrawer.cs:195)
Sirenix.OdinInspector.Editor.OdinDrawer:DrawProperty (UnityEngine.GUIContent) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:109)
Sirenix.OdinInspector.Editor.InspectorProperty:Draw (UnityEngine.GUIContent) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:849)
Sirenix.OdinInspector.Editor.InspectorProperty:Draw () (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:737)
Sirenix.OdinInspector.Editor.Drawers.UnityObjectRootDrawer`1:DrawPropertyLayout (UnityEngine.GUIContent) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/UnityObjectRootDrawer.cs:60)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer (UnityEngine.GUIContent) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:155)
Sirenix.OdinInspector.Editor.Validation.ValidationDrawer`1:DrawPropertyLayout (UnityEngine.GUIContent) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Validation/Core/ValidationDrawer.cs:249)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer (UnityEngine.GUIContent) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:155)
Sirenix.OdinInspector.Editor.Drawers.FixBrokenUnityObjectWrapperDrawer`1:DrawPropertyLayout (UnityEngine.GUIContent) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/FixBrokenUnityObjectWrapperDrawer.cs:41)
Sirenix.OdinInspector.Editor.OdinDrawer:DrawProperty (UnityEngine.GUIContent) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:109)
Sirenix.OdinInspector.Editor.InspectorProperty:Draw (UnityEngine.GUIContent) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:849)
Sirenix.OdinInspector.Editor.PropertyTree:DrawProperties () (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/PropertyTree.cs:552)
Sirenix.OdinInspector.Editor.PropertyTree:Draw (bool) (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/PropertyTree.cs:444)
Sirenix.OdinInspector.Editor.OdinEditor:DrawTree () (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:98)
Sirenix.OdinInspector.Editor.OdinEditor:DrawOdinInspector () (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:232)
Sirenix.OdinInspector.Editor.OdinEditor:OnInspectorGUI () (at C:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:80)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&) (at /Users/bokken/build/output/unity/unity/Modules/IMGUI/GUIUtility.cs:219)