By default, when in Play mode, the Burst compiler compiles jobs asynchronously. To force synchronous compilation, set the CompileSynchronously
property to true
, which compiles your method on the first schedule.
[BurstCompile(CompileSynchronously = true)]
public struct MyJob : IJob
{
// ...
}
If you don’t set this property, on the first call of a job, Burst compiles it asynchronously in the background, and runs a managed C# job in the mean time. This minimizes any frame hitching and keeps the experience responsive.
However, when you set CompileSynchronously = true
, no asynchronous compilation can happen. This means that it might take longer for Burst to compile. This pause for compilation affects the current running frame, which means that hitches can happen and it might provide an unresponsive experience for users.
In general, only use CompileSynchronously = true
in the following situations: