Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug Burst fails to recompile changed code

Discussion in 'Burst' started by Jasper-Flick, May 24, 2022.

  1. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    Case 1427062: Burst does not compile code after first time

    It appears that Burst doesn't check generic types when determining whether a recompilation is required. The consequence of this is that when you edit a type used for generics in a Burst job it doesn't compile again. You're stuck with the binary of the first compilation made by the editor.

    Disabling Burst compilation sidesteps the issue because the C# compiler does recompile correctly, but this makes it impossible to use Burst in the editor. Everything works as it should for a build, it's purely an editor binary caching issue.

    You can make a change in the job type itself as that triggers a recompile, but that is very inconvenient. It should pick up changes to types used by that job via generics just like it does for any other referenced types.

    Note that this is correct application of generics in a Burst job as described in the documentation. Everything works fine in 2020 LTS. It's 2021 LTS that refuses to recompile.
     
  2. sheredom

    sheredom

    Unity Technologies

    Joined:
    Jul 15, 2019
    Posts:
    300
    If you are using Burst 1.7.1 then there is a known issue where it sometimes won't recompile when it should. Should be fixed in 1.7.2.
     
    Per-Morten likes this.
  3. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    I am using Burst 1.6.5. A higher release version is not available via the package manager for Unity 2021.3.2f.
     
  4. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @sheredom I tried Unity 2022.1.4f1 with Burst 1.7.2 and it has the same issue. It is another caching problem, which has still not been recognised by Unity.
     
    arkano22 likes this.
  5. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @sheredom The issue also appears with 2020 LTS in combination with Burst versions starting at 1.6.0. Version 1.5.6 still works as it should. So the issue was introduced in Burst 1.6.0 and has still not been fixed and I have not gotten any feedback from my bug report yet.
     
  6. sheredom

    sheredom

    Unity Technologies

    Joined:
    Jul 15, 2019
    Posts:
    300
    The case hasn't made it to the Burst team yet for some reason, I'm going to chase up why its not made it to us as we shouldn't have had to wait this long. I'll keep you posted!
     
  7. Lee_Hammerton

    Lee_Hammerton

    Unity Technologies

    Joined:
    Jul 26, 2018
    Posts:
    118
    Just to keep you updated. Thanks to your bug report, we've identified the issue and a fix is in progress.
     
  8. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
  9. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    146
    I think I am having similar issue with Burst 1.7.3, when recompiling code (including normal C# code change), Burst stops working until I restart Unity Editor. (version 2022.1.0b6.2664)

    Good that fix is in progress, thanks :).
     
    Last edited: Aug 16, 2022
  10. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    Burst 1.7.4 became available today and I have confirmed that this bug is fixed, although the release notes are not yet online. 1.6.7 is not yet available.
     
    Kobix and sheredom like this.
  11. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    146
    Hello, I updated to 1.7.4, I believe bug is gone now, but if game (editor in playmode) is running and I change code (which forces recompile), editor freezes, and sometimes it just freezes even if not in playmode (freeze when I press play).

    I do use lots of CompileSynchronously on jobs, since Burst doesn't seem to always compile.
     
  12. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    146
    I think I got rid of freeze, might be my mistake?

    Dispose() is called inside OnDestroy, and Dispose() wait for all jobs to finish (via JobHandle..) and Disposes Native structures.

    It could be possible that OnDestroy was never called (does recompile calls it? I dont know), but I added the finalizer code to call Dispose(), if it wasn't called before and now it never freeze on recompile.

    This finalizer is a in MonoBehaviour, btw.

    Code (CSharp):
    1.  
    2.         ~World()  // finalizer, HAS to be called if dispose wasn't called!
    3.         {
    4.             if (isDisposed)
    5.                 return;
    6.  
    7.             Dispose();
    8.         }
    9.  
    Leaving this here for future reference, maybe might be good to mention this in Burst docs?
     
    Last edited: Aug 31, 2022
    chadfranklin47 and sheredom like this.
  13. chadfranklin47

    chadfranklin47

    Joined:
    Aug 11, 2015
    Posts:
    221
    I am using Unity 2021.3.10 LTS with Burst 1.7.4 and I am getting an issue where Burst isn't recompiling bursted code. Sometimes it will recompile but use the changes from a previous save, not the current one. Is there any way to force Burst to recompile? I see elsewhere on the forum to delete BurstCache in the Library folder but I can't do that while Unity is running.

    Edit:
    I moved just the relevant testing code to a new 2021.3.10 project and the issue persisted. However, after moving to a 2021.3.9 project the issue is gone (with both Burst 1.7.3 and Burst 1.7.4) so this seems a different issue related to Unity 2021.3.10? I have not yet filed a formal bug report.

    Edit 2:
    After some more digging, I found the issue was due to my use of an AssemblyInfo.cs file within my assembly. In particular, the AssemblyVersion attribute. In my case, it was due to my use of a LibNoise.Net fork and not removing the file in question (https://github.com/CalmBit/LibNoise/blob/master/LibNoise/Properties/AssemblyInfo.cs). Not sure what changed between Unity 2021.3.9 and 2021.3.10 in regards to that.
     
    Last edited: Sep 20, 2022
  14. Mid_plays

    Mid_plays

    Joined:
    Jan 26, 2022
    Posts:
    22
    Hello im also having issues with my burst compiler switched to like 4 different lts versions and it still didn't fix it it keeps giving me so many errors that it can't find burst compiler attribute and what not
     
  15. Trindenberg

    Trindenberg

    Joined:
    Dec 3, 2017
    Posts:
    395
    Try toggling safety checks on/off, this shows the burst timings so assume it's doing a recompile
     
  16. Mid_plays

    Mid_plays

    Joined:
    Jan 26, 2022
    Posts:
    22
    Thank the issue has already been resolved but now I can't seem to switch from andriod build support to mac build support, everything I try my unity crashes and it doesn't even show report bug anymore, and also can anyone tell be how to actually build for andriod I've been trying it but It just gives me a bunch of folders instead of the app I can run on my phone, and when I try to patch it directly to my phone it just fails
     
  17. chadfranklin47

    chadfranklin47

    Joined:
    Aug 11, 2015
    Posts:
    221
    Just wanted to note that with Burst 1.8.2 & 1.8.3 Unity version 2021.3.20, I'm still having issues with Burst not compiling changes. Toggling safety checks on/off only worked the first time doing so. Restarting Unity and Deleting the BurstCache folder does force a recompile... but that is hardly a solution. Will update if I find anything else.
     
    Last edited: Mar 5, 2023
  18. tim_jones

    tim_jones

    Unity Technologies

    Joined:
    May 2, 2019
    Posts:
    287
    @chadfranklin47 if you're able to reproduce it consistently - i.e. you have the project in state A, you make a specific change B, and then it doesn't recompile when it should - then please could you report a bug via Help > Report a Bug? In general we can only really investigate these "Burst doesn't recompile when it should" bugs when we have the actual project, and the actual specific change, to repro it ourselves.
     
  19. itsonh2610

    itsonh2610

    Joined:
    Jul 15, 2017
    Posts:
    9
    Confirming that I am also experiencing this error. on Burst 1.8.2 and unity 2021.3.16f1 have to change safety check every time changed code .
     
  20. tim_jones

    tim_jones

    Unity Technologies

    Joined:
    May 2, 2019
    Posts:
    287
    @itsonh2610 please could you report a bug via Help > Report a Bug, noting the original state of the code and the change you're making? To investigate this sort of issue we really need to be able to reproduce the issue ourselves.