Safety checks are enabled, I think i even tried without Burst being activated and it sometimes crashed. It happens when our random map was generated and the graph is scanned. We scan the graph with the async method and additionally call UpdateGraph with bounds sometimes.
Maybe a few more interesting things:
It just happens in Build
If run in editor or with development build, then we also get an empty exception which is triggered by some Asserts in JobUtils (UtilityJobs, line 89). So even your Asserts seem to be off in our cases, but not sure why (i’ll immediately debug it now!)
Would it be possible for you to upload an example project in which you can reliably replicate the issue?
Those asserts will catch the errors in the parameter values. When running in a release build any errors may cause the program to crash instead (which is what you are seeing).
Yeah i know that about the asserts, but isn’t it strange that it gets wrong parameters anyway?
Regarding a replication project i’m not sure. Would it help you if I send you a binary of the game? Otherwise i’ll see if i can build a repro project, but it’ll take some time i think.
JobCopyRectangle<float4>.Assert() at C:\...\Library\PackageCache\com.arongranberg.astar@4.3.21\Generators\Utilities\UtilityJobs.cs:line 87
JobCopyRectangle<float4>.Copy() at C:...\Library\PackageCache\com.arongranberg.astar@4.3.21\Generators\Utilities\UtilityJobs.cs:line 116
JobCopyRectangle<float4>.Execute() at C:\...\Library\PackageCache\com.arongranberg.astar@4.3.21\Generators\Utilities\UtilityJobs.cs:line 83
IJobExtensions.JobStruct<JobCopyRectangle<float4>>.Execute() at C:\...\JetBrains\Rider2020.1\resharper-host\DecompilerCache\decompiler\48050808-8AEE-40CA-B708-18FF164A29D5\3f\f754b760\IJobExtensions.cs:line 50
Can you give me a hint on how to that? Just found Unity.Jobs.LowLevel.Unsafe.JobsUtility.JobCompilerEnabled, but this doesn’t seem to change the stacktrace.
You can find it in the menubar. Burst -> Enable Jobs or Enable Worker Threads or something like that.
Alternatively you could just edit the GridGraph.cs code. There is a line where it calls dependencyTracker.ForceLinearDependencies. Make sure it passes ‘true’ as the argument.
That will force it to disable any threading.
Ok, I think i found the cause. Still somehow an error, because in the non-jobbified versions of A* it worked.
When the map is generated we adjust the GridGraph size and center to fit our newly generated map.
var nodeSize = gridGraph.nodeSize;
var width = Mathf.RoundToInt((bounds.size.x) / gridGraph.nodeSize);
var depth = Mathf.RoundToInt((bounds.size.y) / gridGraph.nodeSize);
gridGraph.SetDimensions(width, depth, nodeSize);
gridGraph.center = bounds.center;
If i comment this out, i don’t get the error anymore (but this is not a solution for us). So i’d say it is some race condition between our size changes and the pathfinding. Any idea? Like I said in the earlier versions without jobs it worked - but maybe we just absued the system
Yup. Already found it.
I was trying to copy some earlier data when I resized an array, but if the grid graph had been resized the copying bounds would be incorrect (it shouldn’t even have tried to copy the data if the graph had been resized).