Search Unity

100% CPU usage on all cores when in play mode & editor is out of focus OR minimized (2020.1.1)

Discussion in 'Editor & General Support' started by pastaluego, Aug 10, 2020.

  1. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    I am in 2020.1.1.

    If I go into play mode, CPU usage in task manager hovers around 10% as expected, with no abnormal performance in the profiler.
    But as soon as I tab out of Unity Editor while still in play mode, CPU usage skyrockets to 100% on all 6 cores. Drops back down to 10% as soon as I tab back into Editor.

    Does not happen in old 2019.1/2019.2 backups of the same project.

    Upgraded copies of those backup projects to 2020.1.1 and the problem occurs again, which leads me to believe it has something to do with 2020.1.1 in some way, even if it's due to how my OS (Fully updated Windows 10) is failing to handle 2020.1.1 as a background process. All drivers for all my devices are also up to date.

    Still happens in a completely empty scene and with no custom editor windows in my project.

    The only windows open are the default Unity ones, aka SceneView/GameView/Hierarchy/Inspector/Console/Profiler/etc.

    Even if they're not rendering anything the problem persists.

    What's weird is every new project I make to test it seems to be at 60% CPU in play mode with editor both in focus and out of focus, which is distinctly different than the problem I described, but at the same time 60% seems too high for an empty project, especially since my bloated project is only at 10% when in play mode and editor is in focus.

    New empty projects with 2019.1 or 2019.2 are at <20% when in play mode when in focus or not so there's something wrong with 2020.1 in some way, or at least how my OS is handling the process.

    Also if I go in play mode and let the game run while alt tabbed for 30+ minutes, memory usage climbs, so there's a memory leak in some way, but it doesn't visibly go up when I'm watching it, I just come back to 100% memory usage being used by Unity Editor after noticing I had left it in play mode for awhile.

    I have absolutely no idea how to approach this issue.
     
    Last edited: Aug 11, 2020
  2. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    I have made no headway on this issue. I've tried removing all unused packages in the package manager.
    I've tried closing all subwindows except for the singular unity editor window instance.

    I don't know what else to try, since I don't know what specifically Unity is doing while it's in playmode and while it's alt tabbed so I don't know what to test or even how to test it, especially since the profiler doesn't show anything while the Editor is out of focus and in play mode.
     
    Last edited: Aug 11, 2020
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    That's not enough information to say for sure. Unity by default will try to maximize FPS until it hits a hardware bottleneck, unless you use vsync or Application.targetFrameRate to tell it not to. So what is your GPU usage during this? If I had to take a wild guess, I'd say you probably have high GPU usage while in focus, causing the CPU to have to wait for the GPU (GPU bottleneck). Then when running in the background the GPU is no longer the bottleneck, which allows Unity to hit much higher frame rates until the CPU performance maxes out. Check what the profiler says is happening to frame rates when this occurs.

    This behavior is for example why you should use Application.targerFrameRate if you were creating server builds, otherwise without a GPU in the way you can end up with 100% CPU usage and thousands of frames per second when you don't typically need that.
     
  4. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    GPU is at 1-3% both in focus and out of focus. Again it still happens in an empty scene as well and the profiler shows nothing out of the ordinary in focus. Only started happening after updating to 2020.1 because I tested it in 2 near identical versions of the project back from 2019.1 and 2019.2 where it wasn't happening, and then updated to 2020.1 and it started.

    And yeah I thought it could be a framerate issue when the editor is considered idle while it's alt tabbed, but I also have vsync enabled in the quality settings as well as the in the in-editor gameview settings, so unless play mode has special rules when the editor is alt tabbed, it doesn't look like that is it.

    I will say I've had issues with Nvidia drivers and Unity in the past, but the most recent nvidia driver is a month old now and nobody online seems to have had issues with it for other programs.
     
    Last edited: Aug 11, 2020
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    So there is no FPS difference between in focus and out of focus? What is your FPS when in focus and what is your FPS when the problem occurs? I would not bet on vsync limiting frame rates if it isn't actually rendering anything to the screen, but I don't exactly know what exactly you mean by out of focus (you've said background, which implies nothing to be rendered, but not sure if that is what you mean).
     
  6. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    To clarify what I mean by background, the 100% cpu on all cores occurs in every situation where the Unity editor window does not have Windows10 click focus and is in play mode and not paused.

    This includes the Editor window being maximized and completely visible and rendered on one monitor while another program on my second monitor has click/window focus (as in, any window/program besides the Unity editor has been clicked or alt tabbed to and now has the main focus). And it also includes the Unity Editor being minimized entirely which would mean it's not rendering anything.

    I don't know how to measure FPS while Unity doesn't have focus because the profiler doesn't record it because the editor has historically seemed to halt the editor process entirely when the Unity window doesn't have focus even when in play mode, which is why it's so strange that the fact that despite it still being completely halted, it is now causing 100% cpu on all cores.

    But when in focus, FPS shown in profiler seems normal/nothing out of the usual.
     
    Last edited: Aug 12, 2020
  7. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,449
    It should still record but have you tried the Standalone Profiler? With it, you can minimize the editor while keeping the Profiler open and therefore you can continue monitoring performance.

    Also, have you checked your setting for Preferences > Editor > Interaction Mode?
     
    PassivePicasso likes this.
  8. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    **************************************************************************************************
    EDIT - You can actually skip this post entirely and read the ones after it.
    **************************************************************************************************

    SUPER sorry for such a long post, just wanted to get as much info as possible.

    Preferences > Editor > Interaction Mode is set to Default. I tried the other options out of curiosity but it didn't seem to have any effect.

    I also wasn't aware of the Standalone Profiler so I went through a bunch of tests with it profiling both Editor and the Player while in play mode while both in-focus and out of focus.

    It turns out the other poster @Joe-Censored was completely right. After doing those tests it 100% is a framerate issue, but I don't know why it's happening or how to solve it or why it's only happening with 2020.1 and not 2019.1 or 2019.2 (2019.3 and 2020.2 at this moment are untested).

    The investigative process was basically that in 2020.1 I noticed new and completely empty scenes in both my bloated project and completely new projects were using 60% cpu (measured with task manager) even when in play mode and in focus which is oddly high (still 100% when out of focus), while my complicated scenes were using under 10% cpu usage when in focus (still 100% when out of focus). I realized the new scenes didn't have my Application.targetFrameRate script, so I added it and the new scenes started behaving exactly like my complicated scenes, which is:

    <10% CPU in play mode with editor in focus and completely normal profiler behavior, but then when still in play mode and out of focus, the CPU jumps to 100% on all cores. Which makes sense if for some reason Unity is trying to render 10k frames per second when the editor is out of focus and in play mode.

    Using the standalone profiler I was able to get a somewhat better glimpse into what was happening. I'm not sure how to format everything in a meaningful and digestible way so I apologize if it's messy.

    In an empty scene with just 1 script that sets Application.targetFrameRate = 60 on Start, with VSync Every V Blank in Quality Settings (though I believe VSync doesn't work in editor, but I also have VSync enabled in the GameView resolution settings), but in the profiler I have VSync unchecked to see the true fps.

    The oddities stem from tests 2 and 6.

    Standalone Playmode Profiler


    1. upload_2020-8-13_14-9-34.png Standalone Playmode Profiler - upload_2020-8-13_14-9-34.png in playmode - upload_2020-8-13_14-9-34.png in focus - upload_2020-8-13_14-10-24.png playmode paused
    Profiler Framerate: ~1k fps ignoring vsync
    CPU Usage: 10%
    upload_2020-8-13_14-23-23.png
    Verdict: Normal behavior, makes sense.

    2. upload_2020-8-13_14-9-34.png Standalone Playmode Profiler - upload_2020-8-13_14-9-34.png in playmode - upload_2020-8-13_14-10-24.png in focus - upload_2020-8-13_14-10-24.png playmode paused
    Profiler Framerate: Not available. Even the standalone profiler stops recording when editor process is out of focus, even when the standalone profiler process is in focus. Not sure if that's normal.
    CPU Usage: 100% on all cores if neither Unity Editor or Standalone Profiler process are in focus. But if standalone profiler process is in focus it splits to 50% standalone profiler process 50% Unity Editor in the Task Manager, which is very odd.
    Verdict: Makes absolutely no sense. However, the profiler does record a few frames after I click off the editor process to drop focus, and the profiler points to high EditorLoop usage, which could potentially be normal, but it brings me to the next phase of testing.

    Standalone EditorLoop Profiler

    3. upload_2020-8-13_14-9-34.png Standalone Editor Profiler - upload_2020-8-13_14-10-24.png in playmode - upload_2020-8-13_14-9-34.png in focus - upload_2020-8-13_14-10-24.png playmode paused
    Profiler Framerate: 200 fps
    CPU Usage: ~5-6% of both the editor process and profiler process.
    Profiler Overview: Application.Idle takes up most time at 4ms, which makes sense.
    Verdict: Seems normal, makes sense.

    4. upload_2020-8-13_14-9-34.png Standalone Editor Profiler - upload_2020-8-13_14-10-24.png in playmode - upload_2020-8-13_14-10-24.png in focus - upload_2020-8-13_14-10-24.png playmode paused
    Profiler Framerate: 0 fps (which I think is normal), but even the standalone profiler semi-stops recording when the main editor is out of focus, even if the standalone profiler is in-focus. If I mouse-over the out of focus main editor window, the profiler will record a few frames, but then stop, so it's still listening for events. I don't know.
    CPU Usage: 0%
    Profiler Overview: Application.Idle takes 100+ms
    Verdict: I think this is also normal. I don't know why even the standalone profiler stops recording editor when it's not in focus, but I don't know if that's normal or not. Whether it is, the editorloop behavior itself and cpu usage is all normal. But going to 0 and being taken up by Application.Idle when out of focus is what I believe I remember seeing when checking profiler over the past 5 years.

    Standalone EditorLoop Profiler
    in Playmode

    5. upload_2020-8-13_14-9-34.png Standalone Editor Profiler - upload_2020-8-13_14-9-34.png in playmode - upload_2020-8-13_14-9-34.png in focus - upload_2020-8-13_14-10-24.png playmode paused
    Profiler Framerate: 200 fps, with consistent spikes from ProfilerWindow.Repaint garbage collection.
    CPU Usage: <5%, with the Standalone Profiler Process using 10%
    Profiler Overview: Consistent 5KB garbage collection every frame from GameView.OnGUI.repaint, I think is normal.
    The consistent spikes to 60fps every x frames come from 40KB garbage split equally between
    Application.Tick>Application.UpdateScene>etc>ProfilerWindow.Repaint, and
    Application.Tick>RepaintAllProfilerWindows>ProfilerWindow.RepaintAllProfilerWindows()
    which I think is normal
    Verdict: I think this is all normal, though I don't actually know.

    6. upload_2020-8-13_14-9-34.png Standalone Editor Profiler - upload_2020-8-13_14-9-34.png in playmode - upload_2020-8-13_14-10-24.png in focus - upload_2020-8-13_14-10-24.png playmode paused
    Profiler Framerate: 10,000 fps
    CPU Usage: 100% all cores
    Profiler Overview: Even doing this for just a few second, the Editor would start to hang up and lag and take a long time to exit playmode. When I try to stop recording on the profiler, Unity would spend 30 seconds with a busy window saying it's trying to parse profiler data, up to 100MB or more just from a few seconds of recording. This occurred in none of the other tests.

    I don't know if the actual frame data is abnormal. I just know it's still running at 10k fps when out of focus.
    upload_2020-8-13_16-6-38.png
    Also a Unity busywindow about like a WebSocket.ClientDispatch or something. I couldn't read it in time. But again this happened with no other test. Only this specific combination.
    Verdict: NOT normal. Very strange, no idea what to do. Also again to clarify if neither editor or standaloneprofiler are in focus, it's 100% cpu usage, but if the profiler is focused, it's split 50% between editor process and standalone profiler process. And again to reiterate, when in focus it's all normal with low CPU usage

    7. upload_2020-8-13_14-9-34.png Standalone Editor Profiler - upload_2020-8-13_14-9-34.png in playmode - upload_2020-8-13_14-10-24.png in focus - upload_2020-8-13_14-9-34.png playmode paused
    Verdict: Basically identical to (4). Despite being both in playmode and out of focus like in (6), when *paused* it behaves completely normally and as expected.

    The only other information I have is, if I let playmode stay on in the background while I do other stuff, the UnityEditor process will eventually be maxing out my system memory, but I've unsuccesfully made it happen intentionally. It just seems to happen eventually if I let it run in the background for an hour or more and I come back to it. I tried viewing memory profiler when this occurred once, and I think it said the Profiler was using a major portion of the extreme amounts of system memory.
     
    Last edited: Aug 15, 2020
    Ghat-Smith and Joe-Censored like this.
  9. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    So yeah I can confirm with absolute certainty that the problem is just the fact that the editorloop is still updating when the editor is in playmode and out of focus, and it's running at 10k fps, which is the CPU is taking the brunt of. I don't know why it's happening, if it's supposed to happen or not, and why only 2020.1+. If I had to guess, it's supposed to be doing some form of throttling and it isn't for some reason.

    As far as the maxing out system memory issue and the editor lag during test 6, I think it's just a consequence of the EditorLoop still running at 10k fps when I leave Unity in playmode in the background; if I leave it running for an hour or so in the background the profiler has recorded tens millions of frames of data, which is a lot of memory and the editor hangs up when I switch back into focus because it starts parsing all those frames. For the sake of it, I tried disabling profiler recording and closed the profiler window but the 100% CPU usage issue still occurred because even without the profiler the editorloop is still running unthrottled at 10k fps.

    This is the almost full profiler Overview during a frame when the Unity Editor is in playmode and out of focus. upload_2020-8-15_13-43-54.png

    Don't know if there's anything out of the ordinary there. I just know it's happening 10k times per second and eating up all the CPU.
     
    Last edited: Aug 15, 2020
  10. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    And this is editorloop profiler overview in play mode and out of focus in a 2019.2 project, where it behaves normally and does not send CPU Usage to 100% on all cores.

    upload_2020-8-15_15-11-30.png

    It seems like it does do some internal throttling somewhere but I don't see it labeled in the overview. So I can only imagine for some reason 2020.1 isn't throttling in this situation like it did in 2019.2.

    **Just tested 2019.1 and 2019.3 and just like 2019.2 the problem does not occur.

    If I update any of these projects to 2020.1, the problem starts happening.

    ***Tested with 2020.2 alpha and the same problem occurs. 2019.4 currently untested.
     
    Last edited: Aug 15, 2020
  11. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    Tested 2019.4 and the problem does not occur either, so I can confirm that the problem starts with 2020.1 and is also in 2020.2.

    Also, unrelated, but something I noticed that is unique to 2019.4 is that the profiler seems to run perfectly normally when the editor is in playmode and out of focus. In other versions including 2019.1, 2019.2, 2019.3, 2019.4 and 2020.1 and 2, when I'm in playmode and leave focus, the profiler kind of just stops visually recording until I click back into the editor. This includes the standalone profiler. Sometimes a mouseoover the main editor window will trigger a few repaints of the profiler, but will still stop after those few repaints until I click focus back into the main editor window.

    But in 2019.4 it runs identically when the editor is both in and out of focus, no idea why it's different than the others.

    Though after installing 2019.4 I get this error consistently on each assetdatabase.reload that I can't seem to get rid of. It doesn't seem to have any negative impact on the CPU profiler though.
    upload_2020-8-15_17-35-6.png

    One possibly interesting thing to note is that in 2019.4 the profiler shows EditorLoop>PlayerLoop>WaitForTargetFPS(which is what I believe is the throttle that's supposed to be happening) whereas 2019.1, 2019.2, and 2019.3, despite also not having the CPU usage problem, don't show it. For those versions whatever is throttling seems to be internalized and bundled into the topmost 'EditorLoop' in the profiler overview.
     
    Last edited: Aug 16, 2020
  12. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    Made bug report, though I don't think it's specific to me or this project since it's a fresh, empty project with nothing in it (except for a few packages I tried testing).

    Case
    1270762
     
    Last edited: Aug 16, 2020
    Ghat-Smith and MartinTilo like this.
  13. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    Just for the sake of it I completely uninstalled all Unity versions, deleted all Unity folders in appdata as well as deleted Unity registry entries, not that it'd do anything, but I still had cached stuff from Unity 5.x I wanted to get rid of. And I tried previous versions of my graphics driver as well as a new version that came out yesterday. After reinstalling, problem still happens with 2020.1 and above and not 2019.4 and below.
     
  14. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    @MartinTilo
    I got a response to my bug report but unfortunately the QA rep that responded, with no disrespect to him, must have either misread or misinterpreted everything I wrote because both his worded and video response focused on replicating the scenarios that I had specified were behaving normally instead of replicating the scenarios I had specified were behaving abnormally. I responded to him with extra detail to clarify, but I'll clarify a bit more here as well with video examples just in case there was a similar confusion; sorry for any repeated info.

    1. When NOT in play mode and editor is either in focus or out of focus, everything is normal, whether profiler is recording or not.
    2. When IN playmode and editor is IN focus, everything is normal, CPU is <20% whether profiler is recording or not.
    3. When IN playmode and editor is OUT of focus, CPU skyrockets to 100% whether profiler is recording or not.

    This (3) only happens with 2020.1+. I tested with 2018.3, 2019.1, 2019.2, 2019.3, 2019.4 and the issue does not occur. I even made a 2019.x project where it consistently did not happen and updated that same project to 2020.1 and it started consistently happening immediately.

    Here's a video to showcase my experience on my PC with the same project I used for the bug report.

    Because it can be a little confusing, at the start of the video before I showcase the problem, I quickly swap focus back and forth between each window just so you can easily determine later in the video which window is in focus at any given moment. The window that isn't being overlapped is the one with focus.

    Also, during the test I toggle profiler recording as well just to show that it has no impact on the issue I'm having. Also UNRELATED to my issue, in the video when I gesture over the profiler when out of focus, it's to highlight that the profiler stops updating when the editor is out of focus (except as you can notice, the occasional mouseover event even when out of focus will trigger a repaint). I don't think this is related to the problem because this behavior is common for all Unity versions I've used, including both 2020.x AND 2019.x and even as far back as 5.x, with the ONE exception being 2019.4 which oddly updates properly when either in or out of focus.
    (The same still happens for standalone profiler even though it's a separate process, it just stops updating when editor is out of focus, again except for 2019.4)



    As you can see in the video above, when Unity Editor is in play mode and out of focus (as in when I click on task manager in this video), unity editor CPU skyrockets. It then immediately drops as soon as I click back onto the Unity Editor and it regains focus. The video above completely demonstrates the problem I reported.

    HOWEVER, I want to show you another video of the profiler specifically that could be very relevant to the bug I reported. At the start of the video I will profile the editor this time, and I want you to keep a close eye on the number frames that the profiler has recorded when in the 4 states below. I tried to gesture with my mouse after each subsequent 'mode', those modes being:
    (1)playmode OFF focus ON (occurs between 0 and 32 seconds in video, seems normal)
    (2)playmode OFF focus OFF (also occurs between 0 and 32 seconds, seems normal)
    (3)playmode ON focus ON (between 32-42 seconds, seems normal enough)
    (4)playmode ON focus OFF (starts at 42 seconds, can't be normal)



    As you can see, nothing out of the ordinary in the first 3 scenarios. But as soon as I do (4), where I click OUT of focus when playmode is ON, when I click BACK into focus, the profiler had recorded tens of thousands of frames in the background during just the 2-3 seconds I was out of focus. This does NOT occur with 2019.1, 2019.2, 2019.3, or 2019.4, and only occurs on the unity versions that are having the problem I reported, which leads me to believe it could be connected somehow. And it's why I think it's an issue of the framerate not properly being throttled in some way in scenario (4), because the editor framerate IS being throttled in scenario (2), which is also out of focus. Even though I think they're connected, let me clarify that I don't think the profiler is any root cause of the problem because the problem still occurs when the profiler is not recording. I just think that the profiler recorded framecount (not framerate) from scenario (4) in the second video above demonstrates the problem is affecting the profiler's behavior. It's also reflected in the framerate, but it's much harder to demo that in the video, and I think just the frame count is more than plenty.


    If this issue is only happening to me, then all I can guess is that it could potentially be the way Unity is interacting with my hardware somehow.

    My CPU is i5-8400 and GPU is Nvidia GTX 1050 if that helps.

    Thanks so much if you can find time to look into it but absolutely no worries if you can't because it's not that big of a deal for me to just not leave it in play mode in the background.
     
    Last edited: Aug 30, 2020
  15. HiddenMonk

    HiddenMonk

    Joined:
    Dec 19, 2014
    Posts:
    987
  16. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    I had tried all possible interaction mode values when it was recommended to me earlier in the thread and it does not stop the problem whatsoever, even though it makes sense that it would which is why I think it has to be a bug. (Also the interaction mode setting was added to 2019.4 as well and the problem does not occur in 2019.4)

    To clarify, changing interaction mode does indeed have an effect on editor framerate as expected when the editor is in focus, but when IN playmode and OUT of focus, no matter what interaction mode is set to, the editor framerate still jumps to 10k fps which causes the CPU usage to jump to 100% of available resources.

    My guess based on the frames I was able to profile, is that for some reason Application.Idle isn't being called during that specific scenario (play on, focus off) which is why the editor loop is going up to 10k fps regardless of interaction mode setting values.

    But Application.Idle is being called in every other scenario as expected (play off, focus on), (play off, focus off), and (play on, focus on).
     
  17. HiddenMonk

    HiddenMonk

    Joined:
    Dec 19, 2014
    Posts:
    987
    oh hehe, my bad. I did a word search for "throttling" to see if anyone mentioned the throttling option in preferences, but I didnt search for the word "Interaction".
     
  18. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    Do you happen to have any more info about this issue? It doesn't need to be fixed quickly because I can easily prevent it by making sure I pause playmode before I click on a different window. I'm more curious than annoyed by it.

    To concisely restate the issue, if I enter play mode in 2020.1 or 2020.2 and then click a different window so Unity is no longer in focus, EditorLoop starts running at ~10k frames per second and causes all available CPU cores to crank to 100%. If EditorLoop is profiled during that period, it actively records all of those frames, which eventually causes memory capacity issues if Unity is left out of focus and in play mode for too long. The issue does not occur in Unity 5 to 2019.4, because EditorLoop is appropriately throttled while in play mode and the editor is out of focus. And to clarify, when the editor is in focus, everything behaves normally. The issue only occurs when in play mode and the editor is out of focus.
     
  19. BenkeiSaito

    BenkeiSaito

    Joined:
    Oct 17, 2018
    Posts:
    1
    In my case I find out 2019.2.6f1. have some problems with some hardware, maybe the graphic card because if you start Unity and than open the task manager and you have 80% CPU that means they dont use realy the GPU at this moment. if you scroll to the right and take a look for the GPU engine and you dont see GPU 1 - 3D, that means something goes wrong.
    The solution for this problem was Open UnityHub click on the 3 points at the right side of your project than click on Advanced Project Settings and type -gpu 1, after that you can open your project over hub again. Now you see in the task manger at the GPU engine GPU 1 - 3D that means your project using the GPU right now. This works only if you open your projekt with UnityHub. I hope this helps
     
  20. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    My editor is already using my dedicated gpu according to task manager.

    I originally thought it was gpu related but the fact that the profiler is also recording tens of thousands of frames per second when in the situation specified (playmode on, editor out of focus) but not in any other instance makes me think it's a Unity issue. Not to mention any project made in Unity version 5.6 to 2019.4 doesn't have this issue, but once I take that same project and update it to 2020.1 or 2020.2, the issue starts happening. Those things lead me to believe it's not on my end.
     
    Last edited: Oct 17, 2020
  21. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    It's been another month, I don't want to pester too often since it's not that big of an issue, but do you happen to have any more info regarding this?

    To restate the issue, if I enter play mode in 2020.1 or 2020.2 and then click a different window so Unity is no longer in focus, EditorLoop starts running at ~10k frames per second and causes all available CPU cores to crank to 100%. If EditorLoop is profiled during that period, it actively records all of those frames even when out of focus, which eventually causes system memory to fill up with that data if Unity is left out of focus and in play mode for too long. The issue does not occur in Unity 5 to 2019.4 because the profiler shows that EditorLoop framerate is appropriately throttled while in play mode and the editor is out of focus. And to clarify, when the editor is in focus while in play mode, everything behaves normally. The issue only occurs when in play mode and the editor is out of focus. If I make a project in any version from Unity 5 to 2019.4 it behaves completely normally in and out of focus when in playmode. If I then update that exact same project to either 2020.1 or 2020.2, the problem starts happening with no other changes whatsoever, so it must be due to a change to 2020.1+.
     
  22. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,449
    I'm not involved in the bugfix, since it has nothing to do with the Profiler (which is what I work on), except for it being the messenger used to find out what was happening here.

    I had a look at the ticket and by the latest update by the person working on it, from today, it looks like the issue was found, fixed and backported. I couldn't yet 100% verify this from my phone, not find out which versions to expect that fix on. Also the fix still needs to be verified by Release QA on the versions it lands on, at which point you should get an email as the issue gets closed.

    I just have one last question based on the fix that I saw: are you setting Application.runInBackground to true? If not, how does the behavior change if you do?

    Thank you for your patience and for filing the bug report, and please excuse the delays. I hope the fix reaches you soon. :)
     
  23. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    196
    Oh I didn't even see the ticket was updated, sorry about that.

    I just tested Application.runInBackground and the issue does indeed go away when it's set to true and returns when set to false.
     
  24. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,449
    I'm not sure it's an update that you can see, as it was a developer comment on it and I think those are "internal".

    Good, then I do believe this fix that is in the pipes should be doing the trick for you. In the mean time, you might be able to use
    Application.runInBackground as a workaround.
     
    pastaluego likes this.
  25. ScorphiusMultiplayer

    ScorphiusMultiplayer

    Joined:
    Nov 10, 2018
    Posts:
    66
    upload_2022-12-20_23-21-43.png

    Using unity 2022.2.1. All CPUs are at 100% load..
    When will unity fix this bug ?
     
    citycat3000 and deXter_969 like this.
  26. dyox

    dyox

    Joined:
    Aug 19, 2011
    Posts:
    619
  27. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,449
    The bug 1270762 reported by @pastaluego was fixed in 2021.1 so what you experience there is a different bug with the same symptoms. It is possible that your issue is not known internally so if you could please file a bug report via the editor's menu item
    Help > Report a Bug
    , it can be investigated and fixed.


    Same as above, that may have the same surface level symptoms but a different underlying cause. Please file a bug report as well.