Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Unity freezes in 100% cases when switched to background

Discussion in 'Editor & General Support' started by Gulliver, Jan 2, 2019.

  1. Gulliver

    Gulliver

    Joined:
    Jan 8, 2013
    Posts:
    54
    Hello

    On recently purchased notebook Lenovo Y530 I have the issue with Unity Editor. When I run the game in the editor and switch to other application (Internet browser, VS Code, Evernote or even Task Manager), wait about 5 seconds and then switch back to Unity editor -- it freezes with 100% probability.

    System info:
    CPU: Intel i7-8750H
    RAM: 16 GB (2x8GB DDR4-2666Hz)
    GPU 0: Intel UHD Graphics 630
    GPU 1: NVidia GTX 1050 Ti, 4 GB
    OS: Windows 10 Home
    SSD Samsung 860 Evo 1TB with the latest firmware

    Reproduced on Unity 5.6.5p4 and 2018.3.0f2, with API DX11, DX9, OpenGL3, and any quality settings.
    All drivers updated and reinstalled, RAM tested several times,

    Important notices:
    1. The bug doesn't reproduce when the external monitor is attached.
    2. Without external monitor GPU 0 and GPU 1 loads are about 20 and 50 %. With the external monitor: 0 and 100%
    3. When Unity editor goes to the background -- GPU 1 load drops to 0 % and Unity stop render and update the game.
    4. NVidia settings to use only GPU 1 for all applications -- doesn't matter.

    Found solution:
    1. Go to the Player settings and set 'Run in background' checkbox.
    2. After that -- Unity renders the game even in the background, GPU 1 load never drops.
    3. With attaching VS Code debugger and placing breakpoint -- Unity stops on it, GPU 1 load drops to zero, but after resuming -- everything is fine, the freeze doesn't happen.

    Resume:
    1. Obviously, the bug is related to restoring 3D graphics resources when Unity becomes active. Looks like Unity loses textures/models resources loaded to Video memory when goes to the background and can't restore them when switching back.
    2. Right now I have no time to prepare a sample project and submit the bug because the size of the full project is 15 GB.
    3. If somebody encounters a similar problem -- please reply.

    Thanks