Unhandled Exception issue

I’ll try and let you know if it helped

Ok now i’m having a completely different issue. Tried baking my graphs by exporting like I always do.
So I used this:

    foreach (var graph in AstarPath.active.astarData.graphs)
    {
        if (graph != null)
        {
            AstarPath.active.astarData.RemoveGraph(graph);
        }
    }

to remove the graphs after I baked the first batch but then when I create a graph it throws this error:

NullReferenceException: Object reference not set to an instance of an object
Pathfinding.GridNode.FloodFill (System.Collections.Generic.Stack`1 stack, UInt32 region) (at Assets/AstarPathfindingProject/Generators/NodeClasses/GridNode.cs:235)
AstarPath+c__AnonStorey3.<>m__0 (Pathfinding.GraphNode node) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:1902)
Pathfinding.GridGraph.GetNodes (Pathfinding.GraphNodeDelegateCancelable del) (at Assets/AstarPathfindingProject/Generators/GridGenerator.cs:106)
AstarPath.FloodFill () (at Assets/AstarPathfindingProject/Core/AstarPath.cs:1912)
AstarPath.ScanLoop (Pathfinding.OnScanStatus statusCallback) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:2134)
AstarPath.Scan () (at Assets/AstarPathfindingProject/Core/AstarPath.cs:2017)

Edit: I found you little bug and fixed it. As you can see in AstarData.cs:500 -

        bool foundEmpty = false;
  	for (int i = 0; i < graphs.Length; i++) {
  		if (graphs[i] == null) {
  			graphs[i] = graph;
  			graph.graphIndex = (uint)i;
  			foundEmpty = true;
  		    break;    // This break is missing in the original code. I added it
  		}
  	}

Without the added break, it will just replace all nulls (as many as the number of graphs removed beforehand) with the current one. Please fix it :slight_smile:

Also, it seems like the threading bug still happens:

IndexOutOfRangeException: Array index is out of range.
at Pathfinding.GridGraph.GetNearestForce (Vector3 position, Pathfinding.NNConstraint constraint) [0x00614] in Assets\AstarPathfindingProject\Generators\GridGenerator.cs:778
at AstarPath.GetNearest (Vector3 position, Pathfinding.NNConstraint constraint, Pathfinding.GraphNode hint) [0x0017d] in Assets\AstarPathfindingProject\Core\AstarPath.cs:2893
at Pathfinding.ABPath.Prepare () [0x0009e] in Assets\AstarPathfindingProject\Pathfinders\ABPath.cs:195
at AstarPath.CalculatePathsThreaded (System.Object _threadInfo) [0x000d2] in Assets\AstarPathfindingProject\Core\AstarPath.cs:2501
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
AstarPath:CalculatePathsThreaded(Object) (at Assets\AstarPathfindingProject\Core\AstarPath.cs:2597)

(Filename: Assets/AstarPathfindingProject/Generators/GridGenerator.cs Line: 778)

Then

Unhandled exception during pathfinding. Terminating.
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
AstarPath:CalculatePathsThreaded(Object) (at \Assets\AstarPathfindingProject\Core\AstarPath.cs:2598)

And then

Error : This part should never be reached.
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
AstarPath:CalculatePathsThreaded(Object) (at \Assets\AstarPathfindingProject\Core\AstarPath.cs:2604)

Also, after upgrading i’m starting to get lots of these:

Guid Conflict when importing graphs additively. Imported graph will get a new Guid.
This message is (relatively) harmless.
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogWarning(Object)
Pathfinding.AstarData:DeserializeGraphsPartAdditive(AstarSerializer) (at Assets\AstarPathfindingProject\Core\AstarData.cs:352)
Pathfinding.AstarData:DeserializeGraphsAdditive(Byte[]) (at Assets\AstarPathfindingProject\Core\AstarData.cs:292)
Pathfinding.AstarData:DeserializeGraphs(Byte[]) (at Assets\AstarPathfindingProject\Core\AstarData.cs:277)
GraphBake:ImportGraphs(String) (at Assets\Scripts\AI\Baking\GraphBake.cs:372)
InfluenceMapManager:LoadBakedGraphs(String, Single, String) (at Assets\Scripts\AI\Influence Maps\InfluenceMapManager.cs:152)
InfluenceMapManager:OnPostSegmentSpawnServer() (at Assets\Scripts\AI\Influence Maps\InfluenceMapManager.cs:129)
ActionExtensions:SafeInvoke(Action) (at Assets\Scripts\Utils\ActionExtensions.cs:11)
Assets.Scripts.Managers.GameFlowManager:OnCompletedLoadingSegmentServer() (at Assets\Scripts\Managers\GameFlowManager.cs:655)
ActionExtensions:SafeInvoke(Action) (at Assets\Scripts\Utils\ActionExtensions.cs:11)
Assets.Scripts.Managers.c__Iterator2:MoveNext() (at Assets\Scripts\Managers\SegmentManager.cs:369)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (at C:\buildslave\unity\build\Runtime\Export\Coroutines.cs:17)

(Filename: Assets/AstarPathfindingProject/Core/AstarData.cs Line: 352)

Hey, still waiting for an answer here :slight_smile:

Hi

Sorry about that.
Would it be possible for you to share an example project so that I can replicate this bug?

Ok we’re dealing with 3 bugs here.

  1. I fixed this one for you - you can see it above. Should add it to the version.
  2. The IndexOutOfRange - the problem with this one is that it crashes the whole pathfinding system and it only happens after about a day or two, probably because of a race condition with the threads.
  3. The wrong guid warning - This just happens when exporting and importing graphs

That has already been fixed, but the fix has not been released yet. It was first reported here: Missing break in AstarData.AddGraph()

It just logs that warning because you seem to be additively importing the “same” graph (as in that is based on the same original graph. Each graph get a unique ID when they are created, if you save one instance of that graph to a file and then load it additively twice then you would end up with two graphs with the same unique ID, which we obviously cannot have, so it generates a new ID). You do not need to worry about this.

Ah. Annoying that it happens after so long… Are you perhaps changing the width or depth of the grid graph during runtime?

Also. I could send you the latest development version so you could test that. If we are lucky it has already been fixed (as I have refactored a few things related to multithreading).

…though looking at the stack trace for (3) you do not seem to be loading graphs additively. It must have saved multiple graphs with the same GUID somehow. I’m not sure how that could happen. Do you think you could send me the graph data file that you are trying to load?

But I don’t do that. What I do is create several graphs offline and save them all as one export file. Than I just import that file once in the game. I do import it again but only after I cleared and removed all the graphs. The issue is that I didn’t receive that warning before updating from 3.8.1.

I don’t think so. It happens always after I remove all the graphs, before loading new ones. Sending a version is problematic. But i’ll try to put up a server for the weekend and test if I can reproduce it.

Yes, sure. How do I send it? It won’t allow me to upload this type here.

I have sent you a PM

Um… All your GUIDs are zero…

Do you think you could send me the contents of the GridNodeBase.SerializeReferences and GridNodeBase.DeserializeReferences methods? You are using the 3.8.3 beta version but I only seem to have a version control tag for 3.8.2 and 3.8.4 and I think some things might have changed in those methods between those versions.

I’m pretty sure i’m using 3.8.6 - That’s what the changelog says.

public override void SerializeReferences (GraphSerializationContext ctx) {
  	// TODO: Deduplicate code
  	if (connections == null) {
  		ctx.writer.Write(-1);
  	} else {
  		ctx.writer.Write(connections.Length);
  		for (int i = 0; i < connections.Length; i++) {
  			ctx.SerializeNodeReference(connections[i]);
  			ctx.writer.Write(connectionCosts[i]);
  		}
  	}
  }
  /** Cached to avoid allocations */
  static readonly System.Version VERSION_3_8_3 = new System.Version(3, 8, 3);
  public override void DeserializeReferences (GraphSerializationContext ctx) {
  	// Grid nodes didn't serialize references before 3.8.3
  	if (ctx.meta.version < VERSION_3_8_3)
  		return;
  	int count = ctx.reader.ReadInt32();
  	if (count == -1) {
  		connections = null;
  		connectionCosts = null;
  	} else {
  		connections = new GraphNode[count];
  		connectionCosts = new uint[count];
  		for (int i = 0; i < count; i++) {
  			connections[i] = ctx.DeserializeNodeReference();
  			connectionCosts[i] = ctx.reader.ReadUInt32();
  		}
  	}
  }

Also - It looks greyed out - probably because have ASTAR_GRID_NO_CUSTOM_CONNECTIONS on

Ah, you are right. I misread the version in the file.

I am not sure why those GUIDs are zero, but I tried loading it and then saving it again and that saved it with unique GUIDs. So try doing that and if it still saves the graphs with zero GUIDs then that must be a bug in your version that has since been fixed. Regardless you do not need to worry about this warning.

Thank you. I will update you on the other bug.
When is the new version up?

Ok.

Not sure. As soon as I have written all the compatibility code.

1 Like

Hello again! It’s been quite a few months and versions but i’m still getting lots of the Guid Conflict when importing graphs additively. Imported graph will get a new Guid warning. Any solution for that?

Hi

Have you exported the graphs again or are you using the same graph data as before?

I exported the graphs again

Think you could send the graph files again?

1 Like