iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🧹

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.

State where Burst TypeInitializationException appears in the Console

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:

  1. Close Unity
  2. Delete Library/BurstCache
  3. Reopen Unity

After reopening, the red Burst errors were gone.

State where the red error count became 0 after deleting BurstCache and reopening

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.

GitHubで編集を提案

Discussion