Unity.MissingUnityEvents icon indicating copy to clipboard operation
Unity.MissingUnityEvents copied to clipboard

Causes Burst compiler to throw exceptions.

Open NeistH2o opened this issue 1 year ago • 3 comments

Hi there,

I have been using this tool for quite a while but I just realized today that weaving the DLL causes Burst to throw exceptions.

I updated Unity to a newer version while testing Burst on a default sample project, so the DLL wasn't modified yet, and I thought "Great! The update fixed my Burst problem." But then after returning to my project and casually applying the patch to the DLL, my project compiled but Burst started throwing exceptions again.

I don't think there is anything that can be done to fix this issue but I leave it here to spare anyone else days of research to find out this particular limitation.

NeistH2o avatar Jul 27 '22 14:07 NeistH2o

I created a thread on the Unity forum a few days ago where you can see the error I was getting.

NeistH2o avatar Jul 27 '22 15:07 NeistH2o

Thanks for raising that @NeistH2o.

I'll try to have a look at that at some point. I don't have much experience with burst compiler.

I did see something similar with IL2CPP at one point. The issue there was hooking up directly to events instead of using indirected calls (via helper class) that have conditional compilation symbols in.

Seems IL2CPP was using some different unity dlls (or from different location than editor) and calling events directly caused compiler errors (member not existing / event).

Maybe it's similar for burst.

handzlikchris avatar Jul 30 '22 09:07 handzlikchris

After watching the Unity conference about Burst compiler, it seems that Jobs use a lightweight version of C# that allows them to prevent aliasing and other things, which in turns allows the Burst compiler to optimize the compiled code much much better.

It's a total guess but one of the Job interfaces was made to update Transforms, so perhaps events are simply not part of the Jobs DLL which in turn causes Burst to throw exceptions.

It doesn't prevent Unity to compile but it does prevent Burst to optimize the code it is supposed to optimize.

NeistH2o avatar Jul 30 '22 09:07 NeistH2o