Xbox JIT Exception catch

Hi, i’m porting my game to XboxOne using Unity and I have this catch on my log

Caught exception while deserializing data.
System.TypeInitializationException: An exception was thrown by the type initializer for Pathfinding.Util.ArrayPool1 ---> System.ExecutionEngineException: Attempting to JIT compile method 'System.Collections.Generic.Dictionary2<int, System.Collections.Generic.Stack`1<Pathfinding.TriangleMeshNode[]>>:.ctor ()’ while running with --aot-only.

at Pathfinding.Util.ArrayPool`1[Pathfinding.TriangleMeshNode]…cctor () [0x00000] in :0
— End of inner exception stack trace —
at Pathfinding.BBTree.Clear () [0x0006f] in ProjectPath\Assets\AstarPathfindingProject\Generators\Utilities\BBTree.cs:47
at Pathfinding.BBTree.RebuildFrom (Pathfinding.TriangleMeshNode[] nodes) [0x00002] in ProjectPath\Assets\AstarPathfindingProject\Generators\Utilities\BBTree.cs:82
at Pathfinding.NavmeshBase.DeserializeExtraInfo (Pathfinding.Serialization.GraphSerializationContext ctx) [0x00356] in ProjectPath\Assets\AstarPathfindingProject\Generators\NavmeshBase.cs:1378
at Pathfinding.Serialization.AstarSerializer.DeserializeExtraInfo (Pathfinding.NavGraph graph) [0x00056] in ProjectPath\Assets\AstarPathfindingProject\Core\Serialization\JsonSerializer.cs:612
at Pathfinding.Serialization.AstarSerializer.DeserializeExtraInfo () [0x00015] in ProjectPath\Assets\AstarPathfindingProject\Core\Serialization\JsonSerializer.cs:687
at Pathfinding.AstarData.DeserializeGraphsPartAdditive (Pathfinding.Serialization.AstarSerializer sr) [0x00049] in ProjectPath\Assets\AstarPathfindingProject\Core\AstarData.cs:389
at Pathfinding.AstarData.DeserializeGraphsAdditive (System.Byte[] bytes) [0x00027] in ProjectPath\Assets\AstarPathfindingProject\Core\AstarData.cs:338
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
Pathfinding.AstarData:DeserializeGraphsAdditive(Byte[]) (at ProjectPath\Assets\AstarPathfindingProject\Core\AstarData.cs:348)
Pathfinding.AstarData:DeserializeGraphs(Byte[]) (at ProjectPath\Assets\AstarPathfindingProject\Core\AstarData.cs:322)
Pathfinding.AstarData:LoadFromCache() (at ProjectPath\Assets\AstarPathfindingProject\Core\AstarData.cs:236)
Pathfinding.AstarData:Awake() (at ProjectPath\Assets\AstarPathfindingProject\Core\AstarData.cs:163)
AstarPath:InitializeAstarData() (at ProjectPath\Assets\AstarPathfindingProject\Core\AstarPath.cs:1263)
AstarPath:Awake() (at ProjectPath\Assets\AstarPathfindingProject\Core\AstarPath.cs:1161)

(Filename: D:/Lince/AragamiPlastic2/Unity/Assets/AstarPathfindingProject/Core/AstarData.cs Line: 348)

I’m using version A* Pathfinding 4.0.11 and Unity 2017.1.0p4

Is there something I can do to fix this?

thanks

Hi

Ah. I didn’t think XboxOne used aot. I think you will have to move the link.xml file to the root of the Assets directory as described on this page: https://arongranberg.com/astar/docs/iphone.php.

Hi,

In farst place, thanks for the fast response!

I changed the link.xml file to the root fo the Assets dir,
Also I added the defines In both JsonSerializer.cs and AStarData.cs

The build keeps logging:

Caught exception while deserializing data.
System.TypeInitializationException: An exception was thrown by the type initializer for Pathfinding.Util.ArrayPool1 ---> System.ExecutionEngineException: Attempting to JIT compile method 'System.Collections.Generic.Dictionary2<int, System.Collections.Generic.Stack`1<Pathfinding.TriangleMeshNode[]>>:.ctor ()’ while running with --aot-only.

at Pathfinding.Util.ArrayPool`1[Pathfinding.TriangleMeshNode]…cctor () [0x00000] in :0
— End of inner exception stack trace —
at Pathfinding.BBTree.Clear () [0x0006f] in Project\Assets\AstarPathfindingProject\Generators\Utilities\BBTree.cs:47
at Pathfinding.BBTree.RebuildFrom (Pathfinding.TriangleMeshNode[] nodes) [0x00002] in Project\Assets\AstarPathfindingProject\Generators\Utilities\BBTree.cs:82
at Pathfinding.NavmeshBase.DeserializeExtraInfo (Pathfinding.Serialization.GraphSerializationContext ctx) [0x00356] in Project\Assets\AstarPathfindingProject\Generators\NavmeshBase.cs:1378
at Pathfinding.Serialization.AstarSerializer.DeserializeExtraInfo (Pathfinding.NavGraph graph) [0x00056] in Project\Assets\AstarPathfindingProject\Core\Serialization\JsonSerializer.cs:612
at Pathfinding.Serialization.AstarSerializer.DeserializeExtraInfo () [0x00015] in Project\Assets\AstarPathfindingProject\Core\Serialization\JsonSerializer.cs:687
at Pathfinding.AstarData.DeserializeGraphsPartAdditive (Pathfinding.Serialization.AstarSerializer sr) [0x00049] in Project\Assets\AstarPathfindingProject\Core\AstarData.cs:389
at Pathfinding.AstarData.DeserializeGraphsAdditive (System.Byte[] bytes) [0x00027] in Project\Assets\AstarPathfindingProject\Core\AstarData.cs:338
UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:LogError(Object)
Pathfinding.AstarData:DeserializeGraphsAdditive(Byte[]) (at Project\Assets\AstarPathfindingProject\Core\AstarData.cs:348)
Pathfinding.AstarData:DeserializeGraphs(Byte[]) (at Project\Assets\AstarPathfindingProject\Core\AstarData.cs:322)
Pathfinding.AstarData:LoadFromCache() (at Project\Assets\AstarPathfindingProject\Core\AstarData.cs:236)
Pathfinding.AstarData:Awake() (at Project\Assets\AstarPathfindingProject\Core\AstarData.cs:163)
AstarPath:InitializeAstarData() (at Project\Assets\AstarPathfindingProject\Core\AstarPath.cs:1263)
AstarPath:Awake() (at Project\Assets\AstarPathfindingProject\Core\AstarPath.cs:1161)

(Filename: D:/Lince/AragamiPlastic2/Unity/Assets/AstarPathfindingProject/Core/AstarData.cs Line: 348)

Any more Ideas on what I should do to fix this?

Thanks

I have some news, this error doesn’t happen if I build using IL2CPP.

Just in case this helps to know what is happening

thanks

Hi

The error happens because the compiler has for some reason not detected that the

Dictionary<int, Stack<?[]>>

class should be compiled.

Try to add this code to the BBTree.cs file in your project:

Dictionary<int, Stack<BBTreeBox[]>> dummyField1;
HashSet<BBTreeBox[]> dummyField2;

The only reason that they are there is to make sure that the compiler understands that those classes should be compiled.

I added those two lines on BBTree.cs and The same error keeps happening.
IL2CPP builds keep fixing the error but it would be nice to be able to use mono builds too.

Any more Ideas on what I could do to fix it?

Thanks

Hm… You might need to actually call the constructor. Try

Dictionary<int, Stack<BBTreeBox[]>> dummyField1 = new Dictionary<int, Stack<BBTreeBox[]>>();
HashSet<BBTreeBox[]> dummyField2 = new HashSet<BBTreeBox[]>();

Then make sure the error is really exactly the same. It might spit out a very similar error but for another part of the code which also needs fixing.

I’m having the exact same issue, mildly different log, but I’m pretty certain it’s caused by the same spot. I’ve tried the dummy constructors with no luck. I tried building with IL2CPP but something else seems to be giving me weird build errors.

I’ve tried moving the link.xml file around as well. Unity 2017.3.0f3, A* 4.1.9 Pro.

Here’s the JIT error I’m getting, are there any other potential fixes you could think of?

ExecutionEngineException: Attempting to JIT compile method ‘System.Collections.Generic.Dictionary2<int, System.Collections.Generic.Stack1<Pathfinding.TriangleMeshNode[]>>:.ctor ()’ while running with --aot-only.

at Pathfinding.Util.ArrayPool1[Pathfinding.TriangleMeshNode]..cctor () [0x00000] in <filename unknown>:0 Rethrow as TypeInitializationException: An exception was thrown by the type initializer for Pathfinding.Util.ArrayPool1
at Pathfinding.BBTree.Clear () [0x0006f] in C:\Plastic Workspaces\Hypergun\Hypergun\Assets\AstarPathfindingProject\Generators\Utilities\BBTree.cs:51
at Pathfinding.BBTree.RebuildFrom (Pathfinding.TriangleMeshNode[] nodes) [0x00002] in C:\Plastic Workspaces\Hypergun\Hypergun\Assets\AstarPathfindingProject\Generators\Utilities\BBTree.cs:89
at Pathfinding.RecastGraph.CreateTile (Pathfinding.Voxels.Voxelize vox, VoxelMesh mesh, Int32 x, Int32 z, Int32 threadIndex) [0x001b7] in C:\Plastic Workspaces\Hypergun\Hypergun\Assets\AstarPathfindingProject\Generators\RecastGenerator.cs:919
at Pathfinding.RecastGraph.BuildTileMesh (Pathfinding.Voxels.Voxelize vox, Int32 x, Int32 z, Int32 threadIndex) [0x00181] in C:\Plastic Workspaces\Hypergun\Hypergun\Assets\AstarPathfindingProject\Generators\RecastGenerator.cs:855
at Pathfinding.RecastGraph+c__Iterator1+c__AnonStorey2.<>m__0 (Int2 tile, Int32 threadIndex) [0x00087] in C:\Plastic Workspaces\Hypergun\Hypergun\Assets\AstarPathfindingProject\Generators\RecastGenerator.cs:654
at Pathfinding.Util.ParallelWorkQueue`1[Pathfinding.Int2].RunTask (Int32 threadIndex) [0x00048] in C:\Plastic Workspaces\Hypergun\Hypergun\Assets\AstarPathfindingProject\Utilities\AstarParallel.cs:91

(Filename: C:/~MyProject~/Assets/AstarPathfindingProject/Generators/Utilities/BBTree.cs Line: 51)

Hi

I’m not quite sure how to solve it properly. However as a workaround you should be able to enable ‘ASTAR_NO_POOLING’ under the Optimizations tab.

That worked! Cheers.