A* Pathfinding Project

Warning: "The Grid Graph is not scanned, cannot update area"


#1

I just upgraded to the latest version of A* Pathfinding Project Pro 4.2.7 (from version 4.2.4) and now when I enter play mode I get this warning: “The Grid Graph is not scanned, cannot update area.” It gets logged 8 times.

I think it is because my AstarPath component is not scanned and has no cache startup data. Instead, I load the data from resources on start and deserialize the data like so:

TextAsset data = Resources.Load<TextAsset>("Graphs/AstarData");
AstarPath.active.data.DeserializeGraphs(data.bytes);

Any idea how I can get rid of this warning?


#2

Hi

Do you get any other error messages? Are they logged before or after you load your graph?

When you saved your graph data, did you include the node data? If not then you have to scan the graph after you have loaded it, otherwise it will just load the settings for the graph but it is not actually usable yet.

Another possible reason: If you have any GraphUpdateScene components in your world when the game is started they will try to apply a graph update during Start. Depending on the execution order this may happen before or after the Start method in your code gets called. Unity does not guarantee this order in any way unless you have explicitly specified it, so I suppose it is possible that it changed after the update. You could try to go to the Unity Execution Order settings and make sure that the GraphUpdateScene component will be executed after your code.


#3

I do not get any other warnings or errors. I save both the graph and node data, and it gets loaded it in Start with the warning occurring when I call AstarPath.active.data.DeserializeGraphs(data.bytes). Nothing actually breaks though - at least not that I can notice. Everything seems to work just fine, like it did when I used version 4.2.4.


#4

Hi

I’m pretty sure that warning cannot come from when you call DeserializeGraphs, I think it’s from some other code that is being called before. Do you have any GraphUpdateScene components in the scene at the start of your game?

But yes, it would not break pathfinding in any way. The only side effect is that there are some graph updates that would not have been applied.


#5

I tried this:

Debug.Log("before");
AstarPath.active.data.DeserializeGraphs(data.bytes);
Debug.Log("after");

and got this:

Capture

I did have a script that called AstarPath.active.UpdateGraphs in start, but I called that a frame after and still got the warnings. I even commented it out and got the same result.

I also have a script that extends GraphUpdateScene and calls AstarPath.active.UpdateGraphs in OnPostScan. But I don’t actually scan the graph at runtime so that should not be it either, correct? I disabled that script and got the same result, so don’t think it’s that.

Here’s the entire warning call stack:

The Grid Graph is not scanned, cannot update area
UnityEngine.Debug:LogWarning(Object)
Pathfinding.GridGraph:Pathfinding.IUpdatableGraph.UpdateArea(GraphUpdateObject) (at Assets/AstarPathfindingProject/Generators/GridGenerator.cs:1996)
Pathfinding.GraphUpdateProcessor:ProcessRegularUpdates(Boolean) (at Assets/AstarPathfindingProject/Core/Misc/GraphUpdateProcessor.cs:247)
Pathfinding.GraphUpdateProcessor:ProcessGraphUpdates(Boolean) (at Assets/AstarPathfindingProject/Core/Misc/GraphUpdateProcessor.cs:182)
Pathfinding.WorkItemProcessor:ProcessWorkItems(Boolean) (at Assets/AstarPathfindingProject/Core/Misc/WorkItemProcessor.cs:297)
AstarPath:PerformBlockingActions(Boolean) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:881)
AstarPath:FlushWorkItems() (at Assets/AstarPathfindingProject/Core/AstarPath.cs:1143)
Pathfinding.AstarData:AssertSafe(Boolean) (at Assets/AstarPathfindingProject/Core/AstarData.cs:213)
Pathfinding.AstarData:DeserializeGraphs(Byte[]) (at Assets/AstarPathfindingProject/Core/AstarData.cs:348)
LoadLevelAstarGraph:Load() (at Assets/Dwerve/Scripts/AStar/LoadLevelAstarGraph.cs:25)
LoadLevelAstarGraph:Start() (at Assets/Dwerve/Scripts/AStar/LoadLevelAstarGraph.cs:10)

Here’s the entire LoadLevelAstarGraph script:

using Sirenix.OdinInspector;
using UnityEngine;
using UnityEngine.SceneManagement;

[RequireComponent(typeof(AstarPath))]
public class LoadLevelAstarGraph : MonoBehaviour {

	// We want to do this on start, after the A* path instance gets initialized
	private void Start() {
		Load();
	}

	[Button]
	public void Load() {
		if (!enabled) {
			return;
		}
		Scene scene = gameObject.scene;
		string asset = LevelUtility.ExtractLevelName(scene.name).Replace("Scene", "Graph");
		TextAsset data = Resources.Load<TextAsset>("Graphs/" + asset);
		if (data == null) { // In case we just created this level an no astar graph data exists
			return;
		}
		Debug.Log("before");
		AstarPath.active.data.DeserializeGraphs(data.bytes); // line 25
		Debug.Log("after");
	}
}

#6

Ah. Right. So when a graph update is requested by any object it is put in a queue and executed whenever the pathfinding threads have stopped. When you deserialize a graph it will flush this queue to make sure that all updates for the current graphs have been done (as they could become invalidated by the new graph and all kinds of strange issues). So what has happened is that some object has requested a graph update, and then when you try to deserialize the graph the updates (which are currently queued) will be forced to execute immediately.

I’d recommend trying to switch off the applyOnStart setting on your GraphUpdateScene objects. I think those are what are updating the graphs.