Upgrading to 4.3.61 caused all callback functions to stop working

Today I downloaded and installed the latest version of A* beta to resolve an issue with my layered grid graph. It appears that the upgrade resolved my issue, however, my previously working implementation of pathfinding in general appears to have completely broken.

Normally when something completely breaks I get an error message, but here, I’m getting nothing. No errors, and no warnings. Here’s an example piece of code that kicks off a new path:

public void callPathingFunction() {
  seekerScript.StartPath(transform.position, target.transform.position, OnPathComplete);
  Debug.Log("StartPath called");
}

void OnPathComplete(Path p) {
  Debug.Log("Callback called");
  if(p.error) {
    Debug.LogWarning(p.errorLog);
  }
  else {
    // Send my path to my movement script
    DoMovementStuff(p);
  }
}

Prior to the upgrade to the latest version, this code all worked flawlessly. Now, I get the weirdest outcome: my console shows "StartPath called" but does not show "Callback called". Normally if I got an error message I’d be able to troubleshoot what might be going on, but the complete lack of errors or warnings has me completely stumped on what might be happening here.

What are some troubleshooting steps that I can take in order to resolve this issue?

Hi

Do you have a movement script on the same GameObject? If so, that movement script might be running its own path calculations, cancelling yours. The Seeker only does one path calculation at a time.
If you set A* Inspector → Settings → Path Log Mode to Normal it should log if any path calculations are cancelled.

I have a seeker component and a movement script. The movement script calls the seeker’s StartPath, waits for a path to be returned, and once it’s returned, executes its movement. Prior to 4.3.61, this was working just fine. There aren’t any overlapping or conflicting pathfinding calls.

Yes, it was already set to Normal, and there were no logs or warnings about cancelled paths. I set it to Heavy, and I get the following:

AstarPath Component Destroyed - Cleaning Up Pathfinding Data
UnityEngine.Debug:Log (object)
AstarPath:OnDestroy () (at Library/PackageCache/com.arongranberg.astar@4.3.61/Core/AstarPath.cs:1437)

Destroying Graphs
UnityEngine.Debug:Log (object)
AstarPath:OnDestroy () (at Library/PackageCache/com.arongranberg.astar@4.3.61/Core/AstarPath.cs:1452)

Cleaning up variables
UnityEngine.Debug:Log (object)
AstarPath:OnDestroy () (at Library/PackageCache/com.arongranberg.astar@4.3.61/Core/AstarPath.cs:1461)

Scanning - Process took 209 ms to complete
UnityEngine.Debug:Log (object)
AstarPath/<ScanInternal>d__144:MoveNext () (at Library/PackageCache/com.arongranberg.astar@4.3.61/Core/AstarPath.cs:1857)
AstarPath:Scan (Pathfinding.NavGraph[]) (at Library/PackageCache/com.arongranberg.astar@4.3.61/Core/AstarPath.cs:1648)
AstarPath:Awake () (at Library/PackageCache/com.arongranberg.astar@4.3.61/Core/AstarPath.cs:1269)

Processing Possible Work Items
UnityEngine.Debug:Log (object)
AstarPath:ShutdownPathfindingThreads () (at Library/PackageCache/com.arongranberg.astar@4.3.61/Core/AstarPath.cs:1386)
AstarPath:OnDisable () (at Library/PackageCache/com.arongranberg.astar@4.3.61/Core/AstarPath.cs:1414)
Fusion.NetworkSceneManagerBase:FindNetworkObjects (UnityEngine.SceneManagement.Scene,bool,bool) (at Assets/BL/ThirdParties/Photon/Fusion/Scripts/Prototyping/NetworkSceneManagerBase.cs:134)
Fusion.NetworkSceneManagerDefault/<SwitchSceneSinglePeer>d__5:MoveNext () (at Assets/BL/ThirdParties/Photon/Fusion/Scripts/Prototyping/NetworkSceneManagerDefault.cs:149)
Fusion.NetworkSceneManagerBase/<SwitchSceneWrapper>d__26:MoveNext () (at Assets/BL/ThirdParties/Photon/Fusion/Scripts/Prototyping/NetworkSceneManagerBase.cs:228)
UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr)

Shutting down pathfinding thread #0
UnityEngine.Debug:LogWarning (object)
Pathfinding.PathProcessor:CalculatePathsThreaded (Pathfinding.PathHandler) (at Library/PackageCache/com.arongranberg.astar@4.3.61/Core/Misc/PathProcessor.cs:537)
Pathfinding.PathProcessor/<>c__DisplayClass26_0:<.ctor>b__0 () (at Library/PackageCache/com.arongranberg.astar@4.3.61/Core/Misc/PathProcessor.cs:145)
System.Threading.ThreadHelper:ThreadStart ()

Shutting down pathfinding thread #2
UnityEngine.Debug:LogWarning (object)
Pathfinding.PathProcessor:CalculatePathsThreaded (Pathfinding.PathHandler) (at Library/PackageCache/com.arongranberg.astar@4.3.61/Core/Misc/PathProcessor.cs:537)
Pathfinding.PathProcessor/<>c__DisplayClass26_0:<.ctor>b__0 () (at Library/PackageCache/com.arongranberg.astar@4.3.61/Core/Misc/PathProcessor.cs:145)
System.Threading.ThreadHelper:ThreadStart ()

Shutting down pathfinding thread #3
UnityEngine.Debug:LogWarning (object)
Pathfinding.PathProcessor:CalculatePathsThreaded (Pathfinding.PathHandler) (at Library/PackageCache/com.arongranberg.astar@4.3.61/Core/Misc/PathProcessor.cs:537)
Pathfinding.PathProcessor/<>c__DisplayClass26_0:<.ctor>b__0 () (at Library/PackageCache/com.arongranberg.astar@4.3.61/Core/Misc/PathProcessor.cs:145)
System.Threading.ThreadHelper:ThreadStart ()

Shutting down pathfinding thread #1
UnityEngine.Debug:LogWarning (object)
Pathfinding.PathProcessor:CalculatePathsThreaded (Pathfinding.PathHandler) (at Library/PackageCache/com.arongranberg.astar@4.3.61/Core/Misc/PathProcessor.cs:537)
Pathfinding.PathProcessor/<>c__DisplayClass26_0:<.ctor>b__0 () (at Library/PackageCache/com.arongranberg.astar@4.3.61/Core/Misc/PathProcessor.cs:145)
System.Threading.ThreadHelper:ThreadStart ()

Returning Paths
UnityEngine.Debug:Log (object)
AstarPath:ShutdownPathfindingThreads () (at Library/PackageCache/com.arongranberg.astar@4.3.61/Core/AstarPath.cs:1395)
AstarPath:OnDisable () (at Library/PackageCache/com.arongranberg.astar@4.3.61/Core/AstarPath.cs:1414)
Fusion.NetworkSceneManagerBase:FindNetworkObjects (UnityEngine.SceneManagement.Scene,bool,bool) (at Assets/BL/ThirdParties/Photon/Fusion/Scripts/Prototyping/NetworkSceneManagerBase.cs:134)
Fusion.NetworkSceneManagerDefault/<SwitchSceneSinglePeer>d__5:MoveNext () (at Assets/BL/ThirdParties/Photon/Fusion/Scripts/Prototyping/NetworkSceneManagerDefault.cs:149)
Fusion.NetworkSceneManagerBase/<SwitchSceneWrapper>d__26:MoveNext () (at Assets/BL/ThirdParties/Photon/Fusion/Scripts/Prototyping/NetworkSceneManagerBase.cs:228)
UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr)

I also attached a Pathfinding debugger to one of my seekers, and I get the following:

image

Whenever I make a StartPath call, The ABPath at the bottom of the debugger increases the denominator. For example, it starts at 0/7, then when I call StartPath, it goes to 0/8. When I do this, I see my own "StartPath called" debug log, but never the "Callback called" debug log. This means that something is happening inside StartPath itself that is ultimately not calling the callback function.

Again, this was all working flawlessly in 4.2.17. I also followed the upgrade guide exactly as instructed, so I don’t anticipate any issues with the library or installation.

I downgraded my project back to 4.2.18 and set the logging to Heavy. Here are the applicable logs:

Scanning - Process took 198 ms to complete
UnityEngine.Debug:Log (object)
AstarPath/<ScanAsync>d__141:MoveNext () (at Assets/BL/ThirdParties/AstarPathfindingProject/Core/AstarPath.cs:1777)
AstarPath:Scan (Pathfinding.NavGraph[]) (at Assets/BL/ThirdParties/AstarPathfindingProject/Core/AstarPath.cs:1597)
AstarPath:Awake () (at Assets/BL/ThirdParties/AstarPathfindingProject/Core/AstarPath.cs:1266)

Trying to load data from a newer version of the A* Pathfinding Project
Current version: 4.2.18 Data version: 4.3.61
This is usually fine as the stored data is usually backwards and forwards compatible.
However node data (not settings) can get corrupted between versions (even though I try my best to keep compatibility), so it is recommended to recalculate any caches (those for faster startup) and resave any files. Even if it seems to load fine, it might cause subtle bugs.

UnityEngine.Debug:LogWarning (object)
Pathfinding.Serialization.AstarSerializer:OpenDeserialize (byte[]) (at Assets/BL/ThirdParties/AstarPathfindingProject/Core/Serialization/JsonSerializer.cs:530)
Pathfinding.AstarData:DeserializeGraphsAdditive (byte[]) (at Assets/BL/ThirdParties/AstarPathfindingProject/Core/AstarData.cs:367)
Pathfinding.AstarData:DeserializeGraphs (byte[]) (at Assets/BL/ThirdParties/AstarPathfindingProject/Core/AstarData.cs:351)
PathfindingManager:LoadCachedGraph () (at Assets/BL/Scripts/Pathfinding/PathfindingManager.cs:194)
PathfindingManager:Start () (at Assets/BL/Scripts/Pathfinding/PathfindingManager.cs:172)

Path Completed : Computation Time 5.023 ms Searched Nodes 130 Path Length 15
End Node
	G: 68571
	H: 0
	F: 68571
	Point: (-7.45, -1.90, 2.14)
	Graph: 1
Start Node
	Point: (49.25, 12.27, 13.11)
	Graph: 1
Path Number 4 (unique id)
UnityEngine.Debug:Log (object)
AstarPath:LogPathResults (Pathfinding.Path) (at Assets/BL/ThirdParties/AstarPathfindingProject/Core/AstarPath.cs:816)
AstarPath:<InitializePathProcessor>b__122_1 (Pathfinding.Path) (at Assets/BL/ThirdParties/AstarPathfindingProject/Core/AstarPath.cs:1288)
Pathfinding.PathProcessor:CalculatePathsThreaded (Pathfinding.PathHandler) (at Assets/BL/ThirdParties/AstarPathfindingProject/Core/Misc/PathProcessor.cs:379)
Pathfinding.PathProcessor/<>c__DisplayClass24_0:<.ctor>b__0 () (at Assets/BL/ThirdParties/AstarPathfindingProject/Core/Misc/PathProcessor.cs:108)
System.Threading.ThreadHelper:ThreadStart ()

With these logs, I’m not getting nearly as many. Also notice that I’m getting ‘Path Completed’ logs, which is what I would expect (and they work). When instructing a unit to pathfind, I’m also getting the callback as expected:

image

Whereas on 4.3.61 I was only getting the StartPath debug log.

Also worth noting is that the Pathfinding debugger shows pretty much the same information:

image

Lastly, some additional context worth noting, since it may or may not impact troubleshooting. I have a script that caches the graphs that I use and saves them to a file when a public boolean is true:

byte[] bytes = AstarPath.active.data.SerializeGraphs(new SerializeSettings { nodes = true });
Pathfinding.Serialization.AstarSerializer.SaveToFile(Application.dataPath + "/BL/Other/Pathfinding/" + SceneManager.GetActiveScene().name + ".bytes", bytes);

Otherwise when it’s false, it loads the graphs from file:

AstarPath.active.data.DeserializeGraphs(graphData.bytes);

When I upgraded to 4.3.61 I regenerated my graph files, but that did not resolve any issues.

It would be great to work together towards a resolution here, because this is a blocker in completing my project. I’m more than happy to follow any troubleshooting instructions and/or provide you with any resources from my project. Thanks!!

Since the scoped registry has a whole bunch of development versions, I decided that I’d try and see which version broke pathfinding for my game, and I found the exact build.

4.3.41 works.
4.3.42 is broken.

So whatever changes that were made between those two versions is what catastrophically broke my project.

I don’t know if there’s anything else that I can provide you, but if you need more info I can provide it!

I mean, do you have any other movement scripts than your script which you posted at the top of the thread?
Thank you for narrowing it down to a single version.

I have and utilize other movement scripts in other gameobjects, but that’s the only movement script attached to that particular gameobject.

All pathfinding universally across the project breaks on 4.3.42 and later. If there was an issue with a particular movement script, I would expect just those specific gameobjects to have pathfinding break on them.

Hi

That is very strange.
Do the example scenes still work for you?

When I downloaded the sample scenes, I got compile errors related to Event.current. Noticing that it is a default Unity variable, I realized that my Analytics script was overwriting the Event() class. I disabled my Analytics library, which made all the compile errors go away.

I opened up several examples, and most of them appeared to work. Since I’m on URP, none of the materials rendered properly, but the important thing is that pathfinding was working on them.

“This is promising!”, I thought. So I opened up one of my test scenes, rebuilt my graphs, and started it up. And…

It’s still broken. :frowning:

The good news is that the example scenes work. The bad news is that means something in my project is interfering with pathfinding successfully making StartPath() calls. What’s weird is that 4.3.41 works, while anything after that does not.

One thing I noticed is that some pathfinding logs mention Photon Fusion, which is the library that I use for multiplayer. For example:

Returning Paths
UnityEngine.Debug:Log (object)
AstarPath:ShutdownPathfindingThreads () (at Library/PackageCache/com.arongranberg.astar@4.3.61/Core/AstarPath.cs:1395)
AstarPath:OnDisable () (at Library/PackageCache/com.arongranberg.astar@4.3.61/Core/AstarPath.cs:1414)
Fusion.NetworkSceneManagerBase:FindNetworkObjects (UnityEngine.SceneManagement.Scene,bool,bool) (at Assets/BL/ThirdParties/Photon/Fusion/Scripts/Prototyping/NetworkSceneManagerBase.cs:134)
Fusion.NetworkSceneManagerDefault/<SwitchSceneSinglePeer>d__5:MoveNext () (at Assets/BL/ThirdParties/Photon/Fusion/Scripts/Prototyping/NetworkSceneManagerDefault.cs:149)
Fusion.NetworkSceneManagerBase/<SwitchSceneWrapper>d__26:MoveNext () (at Assets/BL/ThirdParties/Photon/Fusion/Scripts/Prototyping/NetworkSceneManagerBase.cs:228)
UnityEngine.SetupCoroutine:InvokeMoveNext (System.Collections.IEnumerator,intptr)

Another thing that I noticed is that the very first log I get is that the pathfinding component is destroyed:

AstarPath Component Destroyed - Cleaning Up Pathfinding Data
UnityEngine.Debug:Log (object)
AstarPath:OnDestroy () (at Library/PackageCache/com.arongranberg.astar@4.3.61/Core/AstarPath.cs:1437)

Looking at the changelogs for 4.3.42, one of the breaking changes is the order of execution:

  • Changed the order of execution for the AstarPath script to -10000.
    Previously the order of execution was left at the Unity default value which is very unpredictable.
    This may cause issues for you if you relied on Awake to be executed before the graphs were loaded and scanned.
    If you need full control over when the graphs are scanned it is recommended that you disable \reflink{scanOnStartup} and instead call \reflink{AstarPath.Scan(NavGraph[])} manually when you want to scan the graphs.

I’m wondering if the pathfinding library and Photon Fusion aren’t playing nicely together, leading to the AStarPath component getting immediately destroyed and recreated by Fusion, leading to a chain reaction of oddities, including no callbacks in any StartPath() calls. This would also explain why things are broken in my project, while the example scenes still work.

I’d love to try and troubleshoot this by changing the script execution order, but it looks like script order established by packages are read-only.

Seems like this should be a setting that we can control (or at least adjust).

I copied the Library/PackageCache files all over to my assets folder. This allowed me to adjust/remove the script execution order.

Unfortunately, removing the script execution order for all Pathfinding entries did not affect or resolve anything. I’m still getting StartPath debug logs, without any Callback debug logs, so the issue still persists.

Are you aware of any changes to specific files in between 4.3.41 and 4.3.42 that might affect my specific implementation of loading graphs from files or using other third party libraries like Photon Fusion? Those two things I believe are what set my project apart the most from the example scenes.

I cannot replicate this.

bild

I added this script:

using UnityEngine;
using Pathfinding;

public class TestStartPath : MonoBehaviour
{
    public Transform target;
    public void Start() {
        GetComponent<Seeker>().StartPath(transform.position, target.transform.position, OnPathComplete);
        Debug.Log("StartPath called");
    }

    void OnPathComplete(Path p) {
        Debug.Log("Callback called");
        if(p.error) {
            Debug.LogWarning(p.errorLog);
        }
        else {
            // Send my path to my movement script
        }
    }
}

to an empty GameObject. It works perfectly fine.

The only case I can think of which would make your case not work is if you have another component on the same GameObject that also uses the seeker for path recalculations at the same time (those will cancel yours). Or if you try to start paths too quickly (the new path requests will cancel the previous ones).

This is just the unity editor going from edit mode to play mode. It destroys the edit-mode AstarPath component before it goes into play mode.

Given the information that I’ve provided so far, I wouldn’t expect you to be able to reproduce the issue on your end. The sample scenes work for me, which means that the underlying issue is likely going to be a conflicting library that I’m using. Given all the circumstances and research done so far, I suspect the conflicting library is Photon Fusion.

I wasn’t getting ‘pathfinding component destroyed’ logs in the sample scenes, and these debug logs appear after entering play mode.

So, to summarize everything in this thread so far:

  • Pathfinding was working flawlessly in my project on version 4.2.18
  • Pathfinding in my project is broken on 4.3.42 and above (including the latest 4.3.61)
  • However, the sample scenes do work in my project on 4.3.42 and above. This means that 4.3.42 introduced a bug that conflicts with something else in my project
  • I highly suspect that it is Photon Fusion that is the conflicting library.
  • I’m wondering what changes that were made between 4.3.41 and 4.3.42 that could potentially introduce this conflict with other libraries that are in my project.

I think the next step is going to be to share a minimum reproducible project with you. however, i may just end up staying on 4.2.18 and try to figure out a workaround with my layered grid graph issue instead. This upgrade issue is far too hairy for my liking, and my layered grid graph approach might not be the best graph for me after all. And if I end up not using a layered grid graph, then I won’t need to upgrade past 4.2.18.

These are all the commits between 4.3.41 and 4.3.42:

* 230433a5a - Fix edge case when cleaning up grid graph (1 year, 10 months ago)<Aron Granberg>
* 149a00e24 - Fix null ref bug (1 year, 10 months ago)<Aron Granberg>
* dd3851c40 - Update changelog (1 year, 10 months ago)<Aron Granberg>
* 1fd5fc747 - Reserialize Debris.prefab (1 year, 10 months ago)<Aron Granberg>
* 1686988e8 - Update changelog (1 year, 10 months ago)<Aron Granberg>
* 7415fc0e2 - Changed order of execution of the AstarPath script (1 year, 10 months ago)<Aron Granberg>
* 88d2fa9e0 - Update stress test (1 year, 10 months ago)<Aron Granberg>
* fade4b188 - Handle diagonal filtering dynamically to support tags and ITraversalProviders (1 year, 10 months ago)<Aron Granberg>
* 01b31eb34 - Fixed layered hexagonal graphs not working properly (1 year, 10 months ago)<Aron Granberg>
* d9945f274 - Fixed a bug which could cause connections to be calculated incorrectly on layered grid graphs that just so happened to only have a single layer. (1 year, 10 months ago)<Aron Granberg>
* 3ddb554a6 - Fixed grid graph cleanup code (1 year, 10 months ago)<Aron Granberg>
* 11c72a899 - Fixed a bug which could cause some native arrays to not be cleaned up when the game was quit in a non-graceful way (1 year, 10 months ago)<Aron Granberg>
* de52c1d20 - Fixed a bug which could cause a SynchronizationLockException to be thrown (1 year, 10 months ago)<Aron Granberg>
* 7c01a5968 - Disable GUS legacy mode in penalties example (1 year, 10 months ago)<Aron Granberg>
* c08e14028 - Tweak path calculation in terrain example (1 year, 10 months ago)<Aron Granberg>
* 4729fd0f2 - Make NavmeshUpdates use internal pathfinding reference (1 year, 10 months ago)<Aron Granberg>
* bb5f8be4e - Add graph mask field to navmesh cut (1 year, 11 months ago)<Aron Granberg>
* f6a57ccd9 - Add SyncTransforms before and after update step (1 year, 11 months ago)<Aron Granberg>
* cb21edfe1 - [ALINE] Reduced overhead in standalone builds (1 year, 11 months ago)<Aron Granberg>
* 24c911c92 - Fixed a bug which could very rarely cause some node connections between tiles in a recast graph to be missed (1 year, 11 months ago)<Aron Granberg>

The only thing that stands out to me is the execution order change. But you said you already tested if that made a difference… So I’m really at a loss for what could cause this issue.

Yeah, same - I’m also at a loss as to what would cause it.

I’ll probably just stick with 4.2.18 in my project for the foreseeable future, as it covers all of my use cases once I move off the layered grid graph. If in the future I need to upgrade to 4.3.*, then I’ll create a new project with just the components that i can reproduce the issue with, and share it with you.

Thank you for taking the time to help troubleshoot this with me! It’s a bummer that it didn’t end up with a resolution, but I’m okay with that.

1 Like