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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Official Debugging Editor freezes and hangs [Windows Only]

Discussion in 'Windows' started by Unity_Javier, Mar 29, 2022.

  1. Unity_Javier

    Unity_Javier

    Unity Technologies

    Joined:
    Mar 7, 2018
    Posts:
    176
    Hi,
    We’d like to share a debugging technique with you that will allow you to capture call stacks of the Editor when it is hung up and unresponsive. Attaching these call stacks to your bug reports can in some instances help us figure out where and why things are getting stuck, even if you can’t share your projects or other details with us.

    For some time we've been testing out an approach that will help show where the editor gets stuck and is compatible with old and new versions of Unity as well.

    What, you'll need:
    1. Process Explorer from SysInternals
    2. The right dbghelp.dll can be installed from here: Debugging Tools for Windows
    Then, open up Process Explorer, and in there find Unity.exe with the right parameters (i.e. the one that contains -projectpath [your_project_name])

    Inside Process Explorer click on Options -> Configure Symbols and point to the right dbghelp.dll from step 2.

    The Symbols Path should be the path to the Editor folder for the version of Unity you want to debug (i.e. C:\Program Files\Unity\Hub\Editor\[UNITY_VERSION]\Editor\ ). It's important to select the right version of the Editor because it will use the symbols supplied by the PDB files to figure out the name of the functions being executed. Unfortunately, it cannot resolve call stack frames that are using Mono in them.




    Once that is set up, double click Unity.exe in ProcessExplorer, go to the Threads tab, and double click the one that says Unity.exe!WinMainCRTStartup

    That will show the current call stack on the main thread in Unity (like in the picture below). Using this call stack can help us figure out what's going on with the Editor faster, and it might speed up our debugging investigations as well.



    Looking forward to helping out and resolving these issues of the editor getting stuck. Please feel free to use this thread to ask questions and discuss the debugging process. Please don’t use it to report your issues. Use the bug reporter for that.
     
  2. cdr9042

    cdr9042

    Joined:
    Apr 22, 2018
    Posts:
    165
    How do I get dbghelp.dll?
    I follow your link to the download page and download this: https://go.microsoft.com/fwlink/?linkid=2173743
    I open the installer and check the Debugging Tools for Windows
    upload_2022-5-9_16-49-43.png

    It downloads a bunch of msi files. I click on all of them but nothing happens. Where do I get the dbghelp.dll file?
    upload_2022-5-9_16-51-37.png

    The computer does not have Visual Studio installed
     
    Last edited: May 12, 2022
  3. Unity_Javier

    Unity_Javier

    Unity Technologies

    Joined:
    Mar 7, 2018
    Posts:
    176
    Hey, I'll update the post with more instructions shortly, but from the link you gave me, the winsdksetup.exe is the file that gets downloaded, and opening it up gives you the choice to install a few things.
    If you select the "Debugging Tools For Windows" (refer to pic below) it should then install it in the following location by default:
    C:\Program Files (x86)\Windows Kits\10

    upload_2022-5-11_20-40-14.png

    Then, if you can go to the bin\x64 folder you should find DbgHelp.dll and you can then point Process Explorer to use that: C:\Program Files (x86)\Windows Kits\10\bin\x64\DbgHelp.dll

    This looks almost like what you wrote up there, so please let me know if it doesn't work and I can look into it some more.
     
    cdr9042 likes this.
  4. chaoscreater

    chaoscreater

    Joined:
    May 9, 2022
    Posts:
    4
    What if the Unity isn't hanging or freezing, but crashing instead? I can see crash dumps for my Unity games located here:

    %localappdata%\CrashDumps

    Would these crash dumps include the Unity symbols? I would presume not, since the symbols are configured to be loaded in Process Explorer? If we need to analyze the crash dumps, how can we make sure that it includes the symbols?
     
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,526
    Symbols are located next to Unity.exe in Unity installation directory. You can also point the debugger to our symbol server (https://symbolserver.unity3d.com/). Dumps never include symbols.
     
    Unity_Javier likes this.
  6. unormal

    unormal

    Joined:
    Jan 10, 2012
    Posts:
    65
    Having a intermittent "Reloading Domain" issue on 2022.3f1

    upload_2023-6-14_2-12-45.png
     
  7. Unity_Javier

    Unity_Javier

    Unity Technologies

    Joined:
    Mar 7, 2018
    Posts:
    176
    In this callstack, it looks like something is preventing the domain unload from happening.
    Do you have some IDE or a debugger attached? This might be preventing the call from completing.
    If you do have a debugger attached, I would recommend updating the package for the debugger in your project to the latest version, since the Visual Studio team has their eye on this sort of race conditions.

    Does that help?
     
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,526
    I'd also suggest seeing what other threads do. Usually callstack like this indicates that a thread has been started and refuses to finish and Unity must wait for all other C# threads to exit before continuing.
     
    unormal likes this.
  9. unormal

    unormal

    Joined:
    Jan 10, 2012
    Posts:
    65
    It does often happen when debugging, but closing the ide doesn't help/release the editor.

    We have a couple threads running for the game, so that's likely it.

    Any great way to force all accessory game threads to close down when the player stops? (Which is obviously not always a graceful game exit)

    Trap an OnApplicationQuit somewhere and force abort them all maybe?
     
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,526
    That's what the editor does, tries aborting them. However, if they are stuck executing native or plugin code, aborting threads may not work (and that's usually the reason for these complete hangs on domain reloads).
     
    unormal likes this.
  11. Snedden27

    Snedden27

    Joined:
    Jul 4, 2020
    Posts:
    8
    this happens for me when debugging in visual studio 2022 community edition , not sure what packages I should update in the package manager as all of them seem already up to date
     
  12. AticAtac

    AticAtac

    Joined:
    Feb 26, 2014
    Posts:
    25
    I had the same issue with debugging -> stuck on domain reload.
    I was using the asset "Fast Script Reload", by uninstalling it and set the "AutoRefresh" to "Enabled" in the preferences the problem is now gone and i can debug without the editor getting stucked.
    (I should also mention that i am using Unity 2022.3.5f1)
     
    Last edited: Jul 30, 2023