iTranslated by AI
Fixing Unity Burst Errors by Clearing the BurstCache
While working in Unity, I started seeing red Burst-related errors in the Console.
The errors I encountered involved a System.Reflection.TargetInvocationException leading to a System.TypeInitializationException, with Unity.Burst.Intrinsics and Unity.Burst.BurstCompiler.Compile appearing in the stack trace.

At first, I suspected an issue with package dependencies or my code, but the combination of Burst, Collections, and Mathematics in Packages/manifest.json appeared to be in a perfectly normal state.
{
"com.unity.burst": "1.8.29",
"com.unity.collections": "2.2.1",
"com.unity.mathematics": "1.3.3"
}
In such cases, it is faster to first suspect that the Burst cache might be corrupted.
Manually deleting the BurstCache
Close Unity and delete Library/BurstCache in your project folder.
For this project, it was located here:
D:\GitHub\VLiveKit_sandbox\Library\BurstCache
Since it is under the Library folder, this is a cache that Unity will regenerate. It is not something that should be tracked in git, and deleting it will not erase the project's source code.
The steps are simple:
- Close Unity
- Delete
Library/BurstCache - Reopen Unity
After reopening, the red Burst errors were gone.

Memo
Files under the Library folder are essentially generated by Unity, so they should not be included in git. Library/BurstCache should be treated the same way; when you get stuck, delete it and let it regenerate.
As in this instance, if you encounter initialization errors involving Unity.Burst.Intrinsics or BurstCompiler.Compile and your package dependencies are clearly not broken, it is faster to first try deleting Library/BurstCache to check if that resolves the issue.
Discussion