Search Unity

Application reload

Discussion in 'Editor & General Support' started by Zaskar7777, Oct 17, 2020.

  1. Zaskar7777

    Zaskar7777

    Joined:
    Oct 17, 2020
    Posts:
    36
    I have been using Unity since 2014. I never encountered this issue.

    While working, making code changes, saving and coming back to Unity more often I get application.reload message box which is fine as long as it goes away, it remains forever till I end task Unity in Windows using the task manager.

    The earlier experience was so much better.

    Moreover, many other message boxes keep coming like refreshing scenes etc sometimes even when the play mode is on and for a few seconds they appear and go away.

    Application.reload causes a major issue while debugging.

    How to reproduce:

    1. Star debug mode.
    2. Start going through the lines step by step
    3. For some reason you want to go back to Unity to check visual states of any game objects you are stuck application. reload appears and you have to stop the debugger. Hence I can no longer debug now.

    The application.reload sometimes appear while hitting play mode and this is more dangerous it never goes away till I end task as I said earlier.

    I am clueless. Is this a bug or some setting which I need to take care of?

    I have already disabled Auto-refresh in preferences settings.

    Please help.
     
    aidangig56 likes this.
  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    I'm not entirely sure I am following your reproduction description entirely. Does this mean that you have an IDE (e.g. Visual Studio or Rider) attached to the Editor and the code execution paused for debugging (stepping through the code line by line) when you tab back into Unity, and that's when the Editor is frozen?

    If that is the case, than that's how it's always been (nothing new with the Progress bar popup) and I'm not sure how it should behave any different. You'd need to press "continue" or stop debugging (red rectangular button in the IDE) to allow the code execution to resume.
     
  3. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    Does this also only happen when your IDE is attached? Maybe you have a breakpoint in an Update or similar method?
     
  4. Zaskar7777

    Zaskar7777

    Joined:
    Oct 17, 2020
    Posts:
    36
    Thanks MartinTilo for the response.

    There is no breakpoint I am sure. To me this is an issue linked with a larger issue of resetting static variables [Domain reload]. Irrespective of the domain reload being enabled or disabled every now and then when I make a code change and run, the application.reload appears and everything is freezed, till I end task and restart Unity, make a code change, test - freeze- end task - restart Unity.

    As per Unity docs https://docs.unity3d.com/Manual/DomainReloading.html

    I need to reset static vars using the RuntimeInitializeOnLoadMethod, My only problem is I have quite a few static vars and the 3rd party framework I am using has quite a few too. Should I be using this method to find each and every static var and reset?
     
  5. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    If you want to bring down your Enter Play mode times, this might be a worthwhile thing to try.

    However, if the Editor just entirely locks up on entering playmode (and not because you have your IDE attached), I think you'd be best advised to file a bug report, because that sounds like something is majorly broken.
     
  6. Zaskar7777

    Zaskar7777

    Joined:
    Oct 17, 2020
    Posts:
    36
    Just to be sure before I raise the bug, can you please elaborate what you mean by "you have your IDe attached".

    What I can definitely tell you is the Unity editor freezes with application.reload popup infinitely till I end task. Even when I have not attached any debugger or even when I am not in debug mode.
     
  7. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    Yes. I just meant if you have instructed Rider or Visual Studio, or VS Code (or whatever other IDE you are using) to attach to the running editor. If you want to be absolutely sure you do not have your IDE attached, close the IDE and end its tasks.
     
  8. Zaskar7777

    Zaskar7777

    Joined:
    Oct 17, 2020
    Posts:
    36
    I did what you said and I see no different results.

    I have started a brand new project in Unity now and using the same 3rd party frameworks.

    The frameworks create voice and video sharing sessions, When I start a session and during testing, if the session doesn't get closed properly because I am still developing, Unity editor freezes again and I have to end task and restart.
    So which means its definitely to do with static vars resetting, my only concern is Unity should be resetting those once I hit stop play button in the editor.

    Not sure why Unity is unable to do it.

    Hence now during development, I have added a button to close the session forcefully, whenever I close the session before stopping play in editor everything is bliss. If by any chance I stop play without closing the session the same error.

    I am detailing it out so that it helps you. Really appreciate your time.
     
  9. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    Could it be that this framework is hogging some System resources like camera and mic when it isn't shutdown properly? Or does it start up some side processes? With these extra details it feels to me like it could be due to something like that and I can imagine some weird constellations there to cause Unity's Mono VM to be unable to cleanly reload the domain.

    It might still be worth trying to file a bug report but it may also be interesting to simultaneously file one with that 3rd party Plugin.
     
  10. Zaskar7777

    Zaskar7777

    Joined:
    Oct 17, 2020
    Posts:
    36
    Ok, I will file a bug report.
     
    MartinTilo likes this.
  11. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    Once you submit a report, please share the issue ID in this thread for easier follow-up.
     
  12. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    265
    Bump, this started occurring around the same time as the poster, currently 2020.2.2f1 and Rider 2020.3

    When switching Unity to debug mode, then within Rider, attach the debugger to the editor. Now go back to Unity and enter play mode. It will sit at "Application.Reload" indefinitely. This happens across multiple unity projects and even new blank projects.

    I don't know if it is a Rider issue or a Unity issue, or possibly a PC configuration issue (similar to how Unity fails to run or has trouble compiling code & shaders if connected to a VPN, though in this case I am not).

    It seemed to show up in the late 2020.1 or early 2020.2 cycle

    @LeonhardP @MartinTilo

    There is also more reports of it here around the same timeframe: https://answers.unity.com/questions/1763357/unity-editor-infinite-applicationreload-when-debug.html
     
    v-strelchenko likes this.
  13. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
  14. BNJMO

    BNJMO

    Joined:
    Dec 6, 2015
    Posts:
    11
    I use Visual Studio 2019 and Unity 2020.2.1f1 and I have this problem quite frequently.
     
    rwarford and v-strelchenko like this.
  15. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    Hi there :)
    Could you please file a bug report on this?
     
  16. RandomProgrammerPerson

    RandomProgrammerPerson

    Joined:
    May 28, 2014
    Posts:
    1
    I too see this problem constantly over the last few months ( currently using 2020.1.15f1 ). Constant meaning more than 90% of the time I attempt to debug a script

    Attaching visual studio 2019 to unity to debug, with 0 or more breakpoints, results in unity hanging indefinitely after pressing the play button, until I press stop and detach the VS2019 debugger, at which point unity then launches the game, or starts responding again.

    The 'hold on' message that is busy indefinitely is one of the three below:
    EditorApplication.playModeStateChanged
    Application.Message
    Application.Reload

    Occasionally, i also see no 'hold on' message, and unity just becomes unresponsive - this happens after a few failed attempts to attach the debugger and launch the game, and quite often when attempting to attach to an already running game in editor. The only remedy to this is to shutdown / restart unity & VS2019, at which point the issue returns to indefinitely hanging on the 'hold on' messages.

    In all cases, i see high CPU usage in unity and visual studio 2019, and letting it work for several minutes doesnt appear to improve the situation.
     
  17. hummlj

    hummlj

    Joined:
    Oct 14, 2017
    Posts:
    1
    same here :/ Unity 2020.3.0f1 with VS 16.9.1
     
    HongSungGwang, Maeslezo, rswa and 2 others like this.
  18. frankcarey

    frankcarey

    Joined:
    Jul 15, 2014
    Posts:
    14
    Also seeing this with 2019.4 versions of unity and 2018.3.5 version of Rider. I was thinking it was maybe the Rider Plugin being so old, but today I upgraded Rider to the latest version (2021.1) and Unity is 2020.3.2f and the problem is worse than ever.
     
  19. superbybot_unity

    superbybot_unity

    Joined:
    Mar 10, 2018
    Posts:
    1
    Happens to me too. Hope this gets fixed ASAP. I basically have to restart my PC whenever this happens.
     
  20. Coderious

    Coderious

    Joined:
    Mar 28, 2020
    Posts:
    26
    It's happening to me too. I run the program few times, makes changes in the code and then the Application.Reload starts and never ends.
     
  21. slider115

    slider115

    Joined:
    Sep 23, 2019
    Posts:
    5
    It's happening to me too. 2020.3.3. It is somehow linked to me starting a thread. Here's the flow that creates the issue:

    - click button
    - thread starts for open file dialog (StandAloneFileBrowser)
    - select file
    - abort thread

    I can do this as many times as I like in the same 'play' session. When I stop the game and try to start again, I get the 'Application.Reload' that never ends. I have to use the task manager to regain control.

    I recently added the 'abort thread' line in the code to see if that made a difference. It does not.

    I tried it with the VS 2019 IDE attached and with it not attached. No difference.

    If I don't create the thread, everything is happy and I can restart.

    This one has me stumped.
     
    saharz321_unity likes this.
  22. Coderious

    Coderious

    Joined:
    Mar 28, 2020
    Posts:
    26
    Any follow up on that? It happens with both 2020.3.5f1 LTS and 2021.1.4f1

    I've downloaded the latest version to date
     
  23. Coderious

    Coderious

    Joined:
    Mar 28, 2020
    Posts:
    26
    Bump, still happening in 2021.1.5f1
     
  24. Adagio-81

    Adagio-81

    Joined:
    Mar 28, 2015
    Posts:
    19
    I'm having the same problem, except mine is easier to reproduce:

    1. Click the play icon

    That's it. No debugger is attached. I just started Visual Studio, but didn't do anything. "Hold on" window is just showing "Application.Reload" forever
     
    lucassivolella likes this.
  25. jykgod

    jykgod

    Joined:
    Dec 15, 2020
    Posts:
    1
    I use the Unity2020.3.7f1 without opening any IDE.Clicked the play icon, then "Application.Reload" forever.
     
  26. v-strelchenko

    v-strelchenko

    Joined:
    Aug 2, 2019
    Posts:
    13
    I've created a bug report for a similar issue I have, while referencing this post:
    FogBugz (unity3d.com)
     
  27. ImpossibleRobert

    ImpossibleRobert

    Joined:
    Oct 10, 2013
    Posts:
    531
    This is driving me crazy. I switch from 2020.1.17 (where it did not occur) to 2021.1.7 and I am loosing so much time because of this. I found that changing window focus sometimes causes Unity to continue. I can also confirm that having Rider attached in debug mode will cause a huge delay and the MOMENT I press the stop/detach button in Rider Unity continues, it did not stop at a breakpoint nor was it in pause mode.
     
  28. coder89

    coder89

    Joined:
    Oct 26, 2018
    Posts:
    29
    @MartinTilo , I got a fairly minimal repro project for Editor freeze (tested in versions from 2021.1.3 up to 2021.1.9).

    You can find the source code here:
    https://github.com/coder89/arfoundation-mock

    Simply clone the repo, open SampleScene and enter Play Mode. You should see some red background and some dummy planes moving. Then exit and re-enter Play Mode without doing anything else. Editor will go into infinite Application.Reload state. The only way to stop it is to kill Unity Editor.

    From my small investigations here is what is causing it...
    SimulateOcclusion.material accepts dummy shader/material that one can use to simulate rendering of camera.occlusion textures on the dummy AR scene. This mono behavior script is attached to AR Mock/Mock Camera game object. Simply removing that material resolves the problem.

    Changing Domain Reload flag in Editor settings makes no difference.

    Short code structure description: SimulateOcclusion.material is used directly by XRCameraSubsystem.cameraMaterial (or it's fake UnityXRMockCameraSubsystem implementation provided in this project). This material is then used by ARCameraBackground mono behavior (part of AR Foundation) which is attacked to AR Camera game object.

    Hopefully this is helpful for finding the root cause of this issue as it seems to be affecting a lot of developers for moths now and it looks like it still isn't fixed.

    EDIT:
    Bug report: https://fogbugz.unity3d.com/default.asp?1339670_usufrhv3m4it0fi9
     
  29. Azirell

    Azirell

    Joined:
    Oct 16, 2015
    Posts:
    29
    Same here. It's starting impossible to work at all with this bug.

    In my case this issue occurs due to AR Foundation Remote asset. Works fine without it.
     
  30. ImpossibleRobert

    ImpossibleRobert

    Joined:
    Oct 10, 2013
    Posts:
    531
    I also removed multiple packages now like 2d sprite, cinemachine and some more and it becomes quite bearable actually. Still not good but I can work again. These packages should have no effect on domain reload should they? They are forever unchanged once compiled since they are packages and not in my project.
     
  31. coder89

    coder89

    Joined:
    Oct 26, 2018
    Posts:
    29
  32. jnroesch

    jnroesch

    Joined:
    Feb 2, 2018
    Posts:
    6
    we are experiencing the same issue. We are currently upgrading our project from 2019LTS to 2020LTS. Issue does not come up in 2019 but in all versions that we tested from the 2020 lifecycle. New projects do not seem to show this behavior but I am not sure about that (only tested a new empty project with nothing in it). This issue makes developing in unity basically impossible for existing projects.
     
  33. frankcarey

    frankcarey

    Joined:
    Jul 15, 2014
    Posts:
    14
    Hey, one thing that seems to have solved it for us is to set unity to only recompile AFTER you stop play mode. Using 2020.3.4f currently. I can't remember the last time it crashed in a relatively new project, but our old project also made a huge difference.

    Edit > Preferences > General > Script Changes While Playing: "Recompile After Finished Playing"
     
  34. coder89

    coder89

    Joined:
    Oct 26, 2018
    Posts:
    29
    Tried that, doesn't help for my repro project/steps. :(
     
  35. darkyer

    darkyer

    Joined:
    Sep 11, 2013
    Posts:
    21
    I have a similar issue but only if I use my project with Raider 2021.1.3 (I'm using Unity 2020.1.15f1). if I use visual studio as my IDE I don't have this problem.

    PD:With Rider sometimes it get stuck even without being in debug, just by doing a change in the code. I need to kill Unity with task manager and sometimes it even resets my layout when I restart.
     
  36. HeiBaiJie

    HeiBaiJie

    Joined:
    Oct 19, 2017
    Posts:
    1
    I got this reload problem just because of PlasticSCM. It's working well without it. The first time to play, no problem. For the second time, 100% I will get an infinite application. reload.
     
    JPUlisses and lucassivolella like this.
  37. coder89

    coder89

    Joined:
    Oct 26, 2018
    Posts:
    29
    Unity folks just closed the bug I reported on this as "Duplicate" but the previously reported bug has less votes. o_OTherefore, asking everyone who's affected by this to upvote this one now:
    https://issuetracker.unity3d.com/issues/commandbuffer-native-plugin-events-hang-in-the-editor

    @HeiBaiJie, @darkyer, @frankcarey, @jnroesch, @ImpossibleRobert, @Azirell, @v-strelchenko, @jykgod, @Adagio-81, @GilJoWal, @slider115, @superbybot_unity, @hummlj, @RandomProgrammerPerson, @MartinTilo, @BNJMO, @XRA, @LeonhardP , @Zaskar7777
     
    ImpossibleRobert likes this.
  38. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    The issue behind this is quite unusual. I briefly investigated it before passing it to another team.

    When the editor reloads the domain, it first needs to get rid of all managed code. In order to do that, it has to wait until all threads that are "attached" the managed runtime to exit, or it would risk unloading code that is still running and cause a crash.

    The repro in this case uses GL.IssuePluginEvent and passes a managed callback (instead of the native one), which causes the managed runtime to attach to the render thread as it calls your callback on it. Since the render thread will not ever exit (until you exit the whole editor), it causes a deadlock.

    There is a fairly straightforward workaround: do not call into managed code on render thread, which means instead of passing a managed delegate to GL.IssuePluginEvent, pass a native function pointer that comes from a native plugin. While this workaround is straightforward, it might not be very easy to implement based on your project.

    This bug is currently with the scripting team. They will be looking at it and will try to come up with solutions to this.

    Hope I helped!
     
    l_racher, telexistence, Fangh and 2 others like this.
  39. coder89

    coder89

    Joined:
    Oct 26, 2018
    Posts:
    29
    ARFoundation (ARCameraBackground) uses GL.IssuePluginEvent so suggected workaround is not possible without creating a custom camera background renderer.
     
    Fangh likes this.
  40. vanurik

    vanurik

    Joined:
    Mar 28, 2017
    Posts:
    1
  41. LT23Live

    LT23Live

    Joined:
    Jul 8, 2014
    Posts:
    98
    Following up. Was there any resolution for this?

    My recreation steps are the same as this although i am not using PlasticSCM...
     
  42. JonathanFri

    JonathanFri

    Joined:
    Jul 3, 2019
    Posts:
    13
    In our case we used HttpClient.Dispose() in an c# deconstructor. This caused the infinite Reload the second time we hit play in the editor. Very random, but removing that line fixed it
     
  43. pumpkinszwan

    pumpkinszwan

    Joined:
    Feb 6, 2014
    Posts:
    214
    That has sped up my Unity immensely, thanks! It was previously taking at least 5-10 seconds, often more like 30 seconds to restart a scene...now it is instant!
     
    damir2076 likes this.
  44. JPUlisses

    JPUlisses

    Joined:
    Apr 23, 2014
    Posts:
    6
    I get this issue, and after trying the enter play mode settings, I can run easily but at end it will try to reload.

    I manage to crash the program and get an error:
    Cannot connect to Unity Package Manager local server [Unknown]

    from: UnityEditor.EditorApplication:Internal_CallUpdateFunctions ()
     
  45. FANTAS666IXI

    FANTAS666IXI

    Joined:
    Mar 6, 2022
    Posts:
    1
    I have the same issue, at start debuging unity frezze with the "Application.Reload". A light solution is to avoid it using "Attach to Unity and play" instead of just "Attach to Unity".
     
  46. LunarMountainGames

    LunarMountainGames

    Joined:
    Jul 24, 2019
    Posts:
    10
    2022 latest version of unity and still getting this bug.
     
    Wadlo likes this.
  47. LunarMountainGames

    LunarMountainGames

    Joined:
    Jul 24, 2019
    Posts:
    10
    And then to pour salt in the wound, when you kill Unity from the taskmanager because it will never complete, I'll get this error and the only thing that fixes it is restarting windows:

    upload_2022-3-17_16-34-6.png
     
    damir2076 and Wadlo like this.
  48. AppoxV

    AppoxV

    Joined:
    Mar 4, 2017
    Posts:
    4
    The "Application.Reload" Happens once a day for me and since it forces me to restart because of the AssetImportWorker0 popup and I'm using 2020.3.31f1. This is getting extremely frustrating.

    Every time there is a new Unity version i pray you guys have fixed this issue but it's still there.

    Please, prioritize and fix this bug since it COMPLETLY kills your flow.
     
  49. unity_kDeLzMhu8n3MnA

    unity_kDeLzMhu8n3MnA

    Joined:
    Dec 14, 2020
    Posts:
    1
    debugging works for me like 1 out of 20 times, otherwise its just stuck.. how was this still not fixed in two+ years... omg
     
  50. BrianAmihan

    BrianAmihan

    Joined:
    Mar 10, 2022
    Posts:
    15
    Just happened to me in 2021.1.20f1. At the very least, we need more information. "Application.Reload" doesn't leave us a lol to go on in terms of what is going wrong.