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. Dismiss Notice

Bug Massive performance drop when camera moves - all CPU threads spammed with TransformChangeSystem

Discussion in 'High Definition Render Pipeline' started by mgeorgedeveloper, Sep 6, 2023.

  1. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    242
    This is something new that started out of the blue...

    I'm on Unity 2022.3.8 LTS.

    When the camera moves during play mode, the framerate drops to around half.
    In the profiler, under the category "Others", a huge amount of time is spent on "TransformChangeSystem".

    You can see this across all my CPU threads for a total of 140ms per frame!

    Generally speaking, you can find the TransformChangeSystem samples below the following areas on the main thread:
    - PostLateUpdate.UpdateRectTransform
    - LateUpdate.PlayerUpdateCanvases
    - PostLateUpdate.UpdateAllRenderers.

    When the camera stops, the problem is still there, but less so... some of the instances of ChangeSystemUpdate (I believe the first two columns in my screenshot) go away.

    I also notice a huge amount of time spent on the "BoundingVolume" stuff as can be seen in the darker green spread across all the CPU threads.

    Any idea what the heck is going on here? I didn't notice any of this a few days ago, but now it's like this. I'm guessing that something terrible went wrong in the scene, but I'm not sure where to start looking.

    Thanks for any ideas!

    TransformChangeSystem.png
     
  2. Skiriki

    Skiriki

    Joined:
    Aug 30, 2013
    Posts:
    66
    Sounds like something is messed up in your uGUI canvas? Maybe divide and conquer on the canvas? Maybe something 3D is getting assigned as child elements for the canvas?
     
    mgeorgedeveloper likes this.
  3. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    242
    So far unable to spot anything strange going on in the UIs itself.

    I wanted to rule out the possibility that this is only happening in the Editor, so I made a dev build and profiled it. I get 125fps so long as the camera is not moving, regardless of scene complexity. But the slightest movement, and the framerate drops way down and then this:

    TransformChangeSystem-devbuild.png
     
  4. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    242
    *** UPDATE ***

    So I stripped the scene down to nearly empty, ripped out all the UIs, etc. Just getting down to a barebones scene.

    Now in this scenario, when we uncouple CinemachineBrain from the main camera, so that nothing touches the main camera transform, then the weird spamming of "TransformChangeSystem" goes away, and we run at a baseline of 150fps in the editor. Screenshot:

    TransformChangeSystem-empty-good.png

    Now, we enable CinemachineBrain, so that the main camera transform is updated each frame - note however it is not actually moving. In this scenario, immediately all the CPU threads are filled with TransformChangeSystem. Note in this empty scene test, the issue has moved to the EditorLoop part - but this is irrelavent because it will appear somewhere, even in a build (see my previous shots). Having the camera actually move, and having UIs, makes the spamming appear in a lot more places - but evens stripped down to bare bones, it is still clearly happening. Screenshot:

    TransformChangeSystem-empty-bad.png
     
  5. Ne0mega

    Ne0mega

    Joined:
    Feb 18, 2018
    Posts:
    702
    I dont use Cinemachine, but I have noticed if my camera is selected in editor, and I start game mode, frame rate suffers dramatically.

    (Like from 130 fps to 80 fps, with glitchiness and lag spikes)

    This may explain the editor loop switch too.
     
  6. mgeorgedeveloper

    mgeorgedeveloper

    Joined:
    Jul 10, 2012
    Posts:
    242
    Also side note - the issue is not directly related to CinemachineBrain - but rather simply anything that touches the main camera transform - even manually editing the position in the editor drops the frame rate briefly.

    Also - I can confirm this is not the typical "frame rate drop because camera is selected" issue. My case of the threads being spammed with the transform update stuff, is regardless of what is selected, and regardless of editor vs. build (although as stated the issue can "move around" and sometimes fall under EditorLoop).
     
  7. Skiriki

    Skiriki

    Joined:
    Aug 30, 2013
    Posts:
    66
    Could be worth filing a big report for this one