Destroyed node error msg

  • 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)

Hi

Are you handling connections between different point nodes in any custom way?

I use

AddNode(new SkywalkNode(active),(Int3) pos )

call to PointGraph to add nodes
and to connect I use

SkywalkNode.Connect(node, otherNode, cost);

which calls the static function in GraphNode
These are all called in WorkItem and then flushed. The calls are spread over many WorkItem calls. The error happens without any path finding calls. my graph starts with 3D grid and when I test with different sizes of the grid the error sometimes appears. I does not depend on the over all size but specific x,y,z dimensions cause it. I also am getting allocation errors at some dimensions they come in batches and seem to related to removing connections or nodes.

IndexOutOfRangeException: Invalid allocation -2
Pathfinding.Collections.SlabAllocator1[T].GetSpan (System.Int32 allocatedIndex) (at ./Packages/com.arongranberg.astar/Core/Collections/SlabAllocator.cs:121) Pathfinding.HierarchicalGraph+JobRecalculateComponents.RemoveHierarchicalNode (Pathfinding.HierarchicalGraph hGraph, System.Int32 hierarchicalNode, System.Boolean removeAdjacentSmallNodes) (at ./Packages/com.arongranberg.astar/Core/Pathfinding/HierarchicalGraph.cs:276) Pathfinding.HierarchicalGraph+JobRecalculateComponents.Execute () (at ./Packages/com.arongranberg.astar/Core/Pathfinding/HierarchicalGraph.cs:481) Unity.Jobs.IJobExtensions+JobStruct1[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)

Hi

Can you reliably replicate this?
If so, I would be very interested if you could share a test project in which I could replicate this error. :slight_smile:

Yes, I can replicate it. I just have to find the right dimension to cause the different problems. I will make a Unity package and send a google drive link to your email
I also use

node.RemovePartialConnection(otherNode);
otherNode.RemovePartialConnection(node);

to remove connections.

1 Like

I found another thing that affects the error message produced. I delete the graph between runs and sometimes after the first run it switches from connection not found to allocation error. My graph deletion does not run inside a workItem.

public void Setup() {
        AstarData data = AstarPath.active.data;
        var scanGraphs = aStarPath.graphs.ToList().FindAll(g => g is SkyPointGraph).ToArray();
        if (scanGraphs.Length > 0) {
            data.RemoveGraph(scanGraphs[0]);
            //Debug.Log($"Setup assign existing generator.skyPointGraph");
        }
        generator.skyPointGraph = data.AddGraph(typeof(SkyPointGraph)) as SkyPointGraph;
        generator.skyPointGraph.optimizeForSparseGraph = false;
        //Debug.Log($"Setup create generator.skyPointGraph");

    }

I recommend using GraphNode.Disconnect(node, otherNode) instead.

That’d be great. Though I prefer a whole zipped project, for simplicity.

I emailed a zip and instructions to reproduce.
changed local code (not the zipped) to Disconnect()

I have seen a similar error pop up in our project, though we’re using RecastGraphs, Navmesh Cuts, and Graph Updates. I haven’t been able to reproduce it as of yet, but very curious if it could be a related root cause.

Here's the error message we got

InvalidOperationException: A node in a RecastGraph contained a connection to a destroyed TriangleMeshNode.
at Pathfinding.HierarchicalGraph+JobRecalculateComponents+<>c.b__12_0 (Pathfinding.GraphNode neighbour, Pathfinding.HierarchicalGraph+JobRecalculateComponents+Context& context) [0x00057] in <45ab92661c754fde8c30bee620e1bc66>:0
at Pathfinding.MeshNode.GetConnections[T] (Pathfinding.GraphNode+GetConnectionsWithData1[T] action, T& data, System.Int32 connectionFilter) [0x00022] in <45ab92661c754fde8c30bee620e1bc66>:0 at Pathfinding.HierarchicalGraph+JobRecalculateComponents.FindHierarchicalNodeChildren (Pathfinding.HierarchicalGraph hGraph, System.Int32 hierarchicalNode, Pathfinding.GraphNode startNode) [0x000ad] in <45ab92661c754fde8c30bee620e1bc66>:0 at Pathfinding.HierarchicalGraph+JobRecalculateComponents.Execute () [0x00154] in <45ab92661c754fde8c30bee620e1bc66>:0 at Unity.Jobs.IJobExtensions+JobStruct1[T].Execute (T& data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) [0x00001] in :0
at (wrapper delegate-invoke) Unity.Jobs.IJobExtensions+JobStruct`1+ExecuteJobFunction[Pathfinding.HierarchicalGraph+JobRecalculateComponents].invoke_void_T&_intptr_intptr_JobRanges&_int(Pathfinding.HierarchicalGraph/JobRecalculateComponents&,intptr,intptr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,int)

My error was caused by user error. i.e. My code destroyed a node but had a reference to the node in a list I forgot to delete. I then created a connection using the destroyed node. If you destroy and create or connect nodes with your code, adding Debug.Logs with node.position to your code and/or the A* code with checks for node.Destroyed on nodes being used can help find the bug. I think Aron will be making exception coming versions to help people find bugs like mine.