Search Unity

Bug (1386385) ProBuilder Window using a bunch of CPU just sitting there?

Discussion in 'World Building' started by dgoyette, Nov 27, 2021.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    Fairly often, when leaving Unity open for a while, I'll notice that the Unity process is using something like 100% of a CPU core, just sitting there doing nothing. If I restart Unity, it stops doing that for a while, but eventually starts doing it again.

    Today I profiled the editor to see if I could understand what it was up to. I found that the ProBuilder window was responsible for a very large portion of the editor's load. It's basically this every frame in the profiler:

    upload_2021-11-27_16-47-20.png

    If I close the ProBuilder window, that entry goes away. If I reopen it, it immediately opens again. However, if I close and reopen Unity, it goes away again. For a while.

    Is there some valid reason why the window should be using so many resources? This isn't when I'm resizing or moving anything. It's just when Unity is sitting there doing "nothing".
     
  2. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    552
    The editor should not be repainting every frame. Otherwise, that snapshot looks within reason for a complicated IMGUI window. Not to say that this is great performance, but until we move to UI Toolkit there isn't too much we can do.

    The fact that closing and opening Unity fixes this temporarily is leading me to think that this might be an issue with the ProBuilder window subscribing to the update loop callback multiple times.
     
  3. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    Fair enough. It does seem as though the editor window is repainting every frame, since the profiler screenshot I posted is occurring every frame. But probably not worth pursuing if you're going to be moving to UI Toolkit at some point in the somewhat near future.
     
  4. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    I ended up reporting this as bug #1386385.

    It seems this occurs 100% of the time. I don't know why I felt that restarting Unity did anything. I've just testing this out in brand new projects, and the moment the PB Window opens, Unity's CPU usage goes to 20%. Close the PB window, and it goes down to 1-2% or so.

    This is a pretty major Editor performance issue. I've started closing ProBuilder any time I'm not actively using it, otherwise the fans immediately kick in and try to cool things down. Hopefully there's something simple that can be done to fix this, or maybe a workaround, assuming a full rework of the UI isn't coming immediately down the pipe.
     
  5. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    I just wanted to mention that the update to 5.2.0 resolved this. I'm assuming PB switch to UI Toolkit in this update? In any case, I just wanted to say thanks for getting this fixed, as I no longer feel like ProBuilder is melting my CPU. :)
     
    kira0x1 and kaarrrllll like this.
  6. kaarrrllll

    kaarrrllll

    Unity Technologies

    Joined:
    Aug 24, 2017
    Posts:
    552
    Yes, indeed. If you're interested in more details, this is the PR that introduces the change https://github.com/Unity-Technologies/com.unity.probuilder/pull/479.

    tldr: pretty significant performance improvement from switching the main toolbar to UITK.

    Code (CSharp):
    1. | gui   | alloc (kb) | time (ms) |
    2. |-------|------------|-----------|
    3. | imgui | 42.6       | 13.55     |
    4. | uitk  | 3.5        | 3.25      |
     
    kira0x1 and dgoyette like this.