Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Compiling with Burst 1.7.0 sometimes freezes Unity

Discussion in 'Burst' started by Per-Morten, Mar 11, 2022.

  1. Per-Morten

    Per-Morten

    Joined:
    Aug 23, 2019
    Posts:
    109
    I've just updated to Burst 1.7.0, and experience a lot of situations where burst freezes and ends up hanging the editor, forcing us to kill Unity from the task manager. I can't remember experiencing this with burst 1.6.4, or at least not as much as now.

    upload_2022-3-11_16-0-29.png

    I'm a bit unsure what causes this, because it happens quite randomly. Sometimes it happens when I enter play mode, other times it happens when I re-enable burst after having turned it off (for managed debugging) or turning safety checks on or off. Is this a known thing?

    One thing that might be related, after updating to 1.7.0 I can't switch the editor out of debugger mode anymore, it just freezes on Reload Script Assemblies. If I revert back to 1.6.4 then I can switch the editor out of debugger mode.

    upload_2022-3-11_16-35-49.png

    For reference, with burst 1.6.4 I have to wait max a minute for burst to compile stuff.
     
    Last edited: Mar 11, 2022
  2. sheredom

    sheredom

    Unity Technologies

    Joined:
    Jul 15, 2019
    Posts:
    300
    Trying to repro this currently, will update when I know more!
     
  3. sheredom

    sheredom

    Unity Technologies

    Joined:
    Jul 15, 2019
    Posts:
    300
    Can repro, looking into fixing now. Thanks again for the report!
     
  4. Per-Morten

    Per-Morten

    Joined:
    Aug 23, 2019
    Posts:
    109
    Great to hear, any estimate on when a fix would be released? The new inspector makes working with burst so much easier, so I'm really keen on upgrading to 1.7 again as soon as possible :)
     
  5. sheredom

    sheredom

    Unity Technologies

    Joined:
    Jul 15, 2019
    Posts:
    300
    Honestly it'll be a few weeks at a guess. We've not yet worked out why its happening, then gotta get the fix landed etc.

    The only time I've been able to repro the hang is when the debug <-> release mode is switched in the editor, so I'm a bit worried that maybe I'll fix that one and there'll be something else lurking based on your original bug description!
     
    Kmsxkuse, Baggers_ and Per-Morten like this.
  6. Kmsxkuse

    Kmsxkuse

    Joined:
    Feb 15, 2019
    Posts:
    297
    I think I'm experiencing this same issue toggling off burst, using a managed debugger to step-through debug a job, and then turning on Burst compile again after. The burst compiling stalls and I'm forced to task-kill unity and restart it.

    Using Jetbrains Rider IDE and built in managed debugger.
     
  7. sheredom

    sheredom

    Unity Technologies

    Joined:
    Jul 15, 2019
    Posts:
    300
    It looks like this issue is actually in 1.6, but much much less likely. What happens (I've only learned this week!) is that when the editor switches from release <-> debug mode, we need to kill and recreate the Burst child App Domain, and we didn't have a hook for the `OnDomainUnload` of the child domain to let us safetly shut down the Burst code, which meant it called thread abort on all the threads in the Burst package (the background compiling threads) and explosions.

    We think we've got a fix for this locally, just running it through all the hoops now. Best advice for a workaround I can give now is make sure the Background Tasks window has no Burst stuff in it when switching from release <-> debug, and we'll try get a fix out asap.
     
    Kmsxkuse and Per-Morten like this.
  8. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    130
    Hi, I am on version 1.7.4 and I still do experience those issues. (editor freeze on code reload when game is playing, and maybe sometimes even if it is not).

    Few facts:
    * It works without freezes when I disable Burst compilation (albeit slower)
    * For cleanup, I wait on main thread for jobs to finish and then dispose persistent native collections
    * Callbacks where I do Dispose is OnDestroy & ~Deconstructor/Finalizer (finalizer is in MonoBehaviour)
    * Dispose function has boolean "disposed" check, so it only runs Dispose code once
    * I did update Unity version, now at 2022.1.15f1.
    * I also tried other Burst version, 1.8.0 pre 2 (was even worse than now)

    Maybe related:
    * Even when I do not have freezes, coworkers computer (which has Intel instead of AMD) experiences much worse freezing (at the moment he gets lots of freezes when I do not).

    Any hints, how to fix this, or where I should investigate? Is it my fault this happens or is it some deep Burst error? Are there any logs I can take look at?
     
  9. sheredom

    sheredom

    Unity Technologies

    Joined:
    Jul 15, 2019
    Posts:
    300
    Anyway we can get a repro for this? We haven't seen anything like this locally, so a repro would be really helpful.
     
  10. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    130
    Hardly, since the bug exists in huge project and I do not have any idea, how to reproduce it.

    I am still investigation the issue, it may be something else than Disposing/waiting for jobs, since I disabled cleanup part (waiting for jobs & dispose) and it still seems to freeze.

    I will investigate more, one simple question: if Unity freezes, do editor/player logs still get saved?
     
  11. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    130
    Ok, more findings:

    Project freezes in this way:
    - Play #1: fine, no problems
    - stop playing
    - Play #2: also starts, freezes at some point in loading part

    Also I found out, when I switch some Burst settings, like "JobsDebugger" or "Native Debug Mode Compilation",
    I get this "Burst compiling" window that seems to stay forever on.

    upload_2022-9-2_19-5-1.png

    Still unsure, what is going on - and will report more findings.. I am starting to suspect PlayerPrefs corruption & Burst
     
  12. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    130
    I upgraded to Burst 1.8.0-pre.2 and this is error I get, when I open project:

    upload_2022-9-2_23-41-34.png
    and when I start the game, as soon as it starts a bursted job it freezes.

    Edit: That error shows up but now I think it runs fine without freezing.

    After rebuilding project .csproj files it seems to work fine.. but it acts this way a lot, I can change one random setting, and it starts working fine, or freezing again?
     
    Last edited: Sep 2, 2022
  13. Kobix

    Kobix

    Joined:
    Jan 23, 2014
    Posts:
    130
    Tested on fresh clean machine with fresh Unity install, no issues for now. Might me my fault after all, will keep investigating whats up - sorry for bothering you all with this!
     
    sheredom likes this.