Burst and Asserts - full of surprises and (un)intuitiveness

Hi, while creating a little something with Burst I’ve came across the need to have some asserts in my burst’ed jobs (after all asserts are good!) but found that the experience is solely lacking. Thanks to amazing Jackson Dunstan’s blog-post I was able to understand why the normal UnityEngine.Assertions.* don’t work (dropping them silently is a big issue IMO) and how to replace them to a certain degree.

But not being able to replicate support for custom fail-messages in my own code in any relatively straightforward way was a real bummer. I finally came to a reasonable solution that uses LogError and throws an exception directly after that but I believe the story could be improved substantially.

More details here: Asserts with custom messages in Burst Unity

TL;DR:

  • Unity asserts are silently dropped in Burst.
  • No exceptions that accept FixedStringXYZ.
  • Some string interpolations are silently dropped in Burst.

Thanks for the blog post, indeed, we are aware of this and we hope to improve the support in a future version of Burst for both asserts and exceptions.

1 Like

Would be nice if Asserts work and they’re replaced with
Unity.Burst.CompilerServices.Hint.Assume on release build.