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

Question Unity Profiler is incomplete?

Discussion in 'Editor & General Support' started by McMagmaz, Jun 21, 2023.

  1. McMagmaz

    McMagmaz

    Joined:
    Mar 30, 2018
    Posts:
    9
    I posted another thread about lag spikes that isn't getting responses.
    So I decided to try and figure it out on my own... unity is lagspiking about once every second when in playmode.
    Here is an empty new scene without ANY scripts. just a fully default stock camera for rendering in a view in Game/play mode.
    upload_2023-6-21_19-18-28.png

    Can anyone tell me what I need to do to debug this thing? the profiler is showing absolutely nothing about where this frametime is coming from.

    RTX 3080 10gb, i9 10900K, hdrp pipeline, fully empty scene with deafult camera and 1 deafult directional light. no scripts; no settings on the camera or light even touched by me.

    I am a AAA dev, wanting to pickup Unity on the side in case I want to work with it in the future.
    And I've had so many ridiculous issues with no solutions. And If I can't get this one fixed anytime soon. I am never touching Unity again. that's how bad it's been.
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,718
    Click the dropdown to expand that PlayerLoop section, and you can further turn on Deep Profiling if that doesn't reveal enough info.
     
  3. halley

    halley

    Joined:
    Aug 26, 2013
    Posts:
    1,834
    If you can't pin it down to your own code, almost surely it's the Unity Editor doing a giant garbage collection cycle. Performance in the Unity Editor is not representative of performance in a build. You can get insights into your own code's issues with the deep profiling (as @PraetorBlue mentioned) but to really understand if you have FPS spikes, you will need to make a build.
     
  4. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,082
    Click-and-drag the white vertical bar until it is over top of the spike. The bar represents the frame that you are viewing the information for. Below is a video I highly recommend taking the time to watch as it covers what you need to know to start making good use of the profiler.

     
    Last edited: Jun 21, 2023
  5. McMagmaz

    McMagmaz

    Joined:
    Mar 30, 2018
    Posts:
    9
    I am over the spike(there is another one in front of this one. but the white bar is exactly over a spike; that's why it says 12.64ms next to it.) There is no information about where the 12.64ms is coming from. only about 1.922 ms from playerLoop.
     
  6. McMagmaz

    McMagmaz

    Joined:
    Mar 30, 2018
    Posts:
    9
    I already did that of course; I didn't open it up for the screenshot; but in that screenshot you can see that playerloop was only accounting for 1.922ms, opening it up only showed the expected HDRenderPipelineRenderCamera to be responsible for all of that 1.922ms as there is literally nothing else in the scene. so the other 11ms came from only God knows where which I am trying to figure out.

    Using Deep profiler as you mentioned shows nothing helpful either. It adds ms to my every frame of the simulation. but the results are the exact same as before; just worse (seriously how bad is the performance of the Unity profiler graphs??)
    Here is a screenshot with Deep profiling. The issue is the exact same; everything is just pushed like 10-20 ms worse with the Deep profiler graphs rendering.
    upload_2023-6-21_22-40-27.png
    GPU on the spike I am hovering is 33.62ms. the profiler hierarchy shows only 12.645ms accounting for 37.6% of the total; there is nothing else using ANY ms below it (nothing below PlayerLoop dropdown that is not on 0.0ms)
     
  7. McMagmaz

    McMagmaz

    Joined:
    Mar 30, 2018
    Posts:
    9
    I can't pin it down to my code as I don't have any. I tried the deep profiler and posted screenshot. but nothing changed except for making all frametimes worse.

    EDIT: In my original post I went on a rant from this point on; I'll leave it here; but I lost control a bit.(whatever I said I do actually think though. Just a bit much if you don't care about anything besides the issue I am having in this thread)

    But about what you said with the performance of the Unity Editor is exactly what I am trying to fix. I know this issue isn't there in the Build. I have build it multiple times and tested multiple things. it is not an issue in the build. I am not trying to ship an android game however. I am trying to see how I can use Unity profesionally. Whether it could at any point be useful for creating AAA quality VFX. And if this is how the editor runs, It is simply useless to even consider it.

    not just saying that because of this particular issue; I have spent 2 days now 'fixing' issues that don't have any proper fixes. Stuff like; why do all my Materials become a flat shaded husk of the actual shader after building? not broken and pink textured; just literally a husk of what it's supposed to be. for example an orange flame shader becomes just a full orange coloured diffuse plane. no movement/transparency whatsoever. And what is the "fix" I found after trying millions of things? rebuilding VFX graph everytime I save any asset in the project. because if I don't; the next build will F*** up all shaders again...

    I have no idea whether all of these things are issues with Unity; or Unity HDRP specifically. but if Unity works fine and Unity HDRP is the reason all of these things are S***. then what I thought about the Unity vs Unreal debate is false and Unity becomes absolutely useless as a tool if you don't plan on rewriting the whole engine to fix half the things.
     
    Unifikation likes this.
  8. McMagmaz

    McMagmaz

    Joined:
    Mar 30, 2018
    Posts:
    9
    Sorry for posting x times in a row; but I just downloaded URP template and it is working fine there; no issues.

    It is kind of useless to me though as I am looking into Unity to see whether I can use it in any cases above my current toolset (in house engines and UE5) and without hdrp; Unity cannot compete at all...

    So I really hope I can fix this issue with hdrp. I don't want to give up on unity this early.
     
    Unifikation likes this.
  9. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,082
    Here's mine. Unity 2023.1. HDRP template without samples. Ryzen 9 5950X. RTX 3070. 1440p. Windows 11.

    upload_2023-6-21_22-3-23.png

    Edit: On a theory I decided to try it without hitting the "Fix All" in the wizard that initially appears which mostly means that the editor is running in DirectX 11 rather than 12 but the only difference appears to be a decrease in average performance. I had heard that it was running better but I wasn't expecting that much of a difference.

    upload_2023-6-21_22-30-47.png
     
    Last edited: Jun 22, 2023
  10. McMagmaz

    McMagmaz

    Joined:
    Mar 30, 2018
    Posts:
    9
    I tried creating an entirely new project, and with just HDRP; things are somewhat ok. (the profiler still shows spikes that are unnoticeable in framerate, but it's still worrying to me as it's an empty scene. I can not work in Unity if the issue gets worse in an actual project context)

    however the specific spikes I was getting instantly appeared when I used the hdrp wizard to turn on HDRP+DXR
    literally instantly the exact same issue. And the worst part is; the issue minimized itself when you select "EventSystem" in the hierarchy during play mode. (which was in the default scene in my previous project when I added everything with the hdrp wizard..., it didn't appear this time :rolleyes:) how does that even make any sense
     
  11. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,026
    When Unity can't/won't or don't provide bassline, default demonstrations of their systems working flawlessly, out of the box, I think it's a sign.

    I don't mean this lightly, despite it looking like a flippant sentence, it is not. It might be that that system, whatever it is, isn't ready for demonstrating flawlessly, or hasn't even been sufficiently internally examined to see if it's actually fit-for-purpose.
     
    McMagmaz likes this.
  12. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,140
    Hey there,
    Just chiming in a bit but, yes, we're aware that the GPU profiling capabilities are... improvable/ready for a rework. We've already reworked the underlying low-level system for capturing the timings on all architectures, APIs and platforms but that mostly just affected the availability and accuracy of FrameTimingManager and ProfilerRecorders, not the GPU Profiler Module, which still needs a complete rework. (For starters, its mimickry of a single threaded hierarchy with GPU timings attributed to CPU samples with the same name as the commands they issued doesn't exactly mesh with the reality of modern graphics APIs)

    It was a consideration for planning but currently has been postponed for other priorities (as you noted there's more than one thing in Unity that could do with an overhaul).

    As for the topical question: iirc GPU timings for stuff happening outside the game view was not (always?) captured by the Profiler. I'm a bit fuzzy about the details and specific Unity version tight now but I think we might have changed it so the high-level GPU timing would include it (your 12.65 ms) via the high-level FrameTimingManager stats, but details for which commands took how long where not (also see the mentioned architectural clash given the current UI for this module).

    So the remaining time was possibly spend on drawing the SceneView, an Inspector preview, the graphs of the Profiler itself, some compute shader running in the background, or anything else within the Editor. Also, changing your selection changes what the inspector shows and might lead to a higher or lower repaint rate on some editor panels or what scripts run alongside as a side effect of the Inspector UI or SceneView gizmos.

    To bridge the gap to the availability of better Unity integrated GPU profiling, you can use native platform specific GPU profilers. This how to guide might help you with that.
     
  13. McMagmaz

    McMagmaz

    Joined:
    Mar 30, 2018
    Posts:
    9
    I will give 3rd party profiling tools a shot; but I kind of doubt it's going to give me any hyper specific information which is exactly what I need here. I know someone else in this thread already tried by making a new project with hdrp and tested it. but I always chose the hdrp+dxr myself and that's where the issues are. I tried to disable everything dxr related but it still happened.

    So If someone could give the HDRP+DXR settings a try with the HDRP setup wizard; I'd be interested in the result. It's possible that everyone has this but is used to this kind of lag in editor as it doesn't appear in the build. I am not however; and I don't think I should be expected to build an executable everytime I want to test something properly. Lagspikes are unacceptable from a realtime VFX standpoint as it will stop me from being able to view ANYTHING I make with Unity HDRP + DXR properly.

    About the UI changing the repaint rate. I tested extensively (that's how I figured out selecting "Eventsystem" somehow magically makes the issue less apparent) and what I found is that when I close all panels aside from the game view itself, it STILL depends on what I selected in the hierarchy before I closed the panels......????
    If i selected Eventsystem and then closed all panels; the lagspikes minimize by quite a bit.
    If i selected anything else and then closed all panels; the lagspikes stay...
     
    Unifikation likes this.
  14. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,026
    Yes, noticed this, too, in different testings, with Builtin Renderer, and the Game View Maximised, all objects deselected... that the last selected is probably still firing strings of its data/values somewhere, and that's probably causing all sorts of performance issues.

    Then they say you must use Builds... and that, unfortunately, is where you're going to start thinking about UE all over again, because building HDRP and URP projects that use any of the new features (DOTS etc) take forever to build.

    At that point, you might as well suffer the build times of Unreal, be sure of the visual fidelity and relax into that approach to making something of that production value.

    Unity, I think, is not fit-for-purpose when it comes to high production values, at this point in time.
     
    McMagmaz likes this.
  15. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,026
    Is there any endeavour underway to provide Unity usage of GPU insights for Mac and iOS, and now VisionOS, within Unity?
     
  16. McMagmaz

    McMagmaz

    Joined:
    Mar 30, 2018
    Posts:
    9
    Sadly, I am starting to come to this conclusion too, as someone who knows UE rather well; I don't see any benefit in Unity at the moment. I thought there would be at least something here but It's been a bit shocking this week. (seeing Unity 2023 not being auto selected and still being in "beta" kind of gave it away already, i tested both the LTS 2022 release; and the 2023 beta; issue persists in both)
     
  17. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,140
    Afaik ProfilerRecorders should work for all of these. As for the GPU Profiler Module: no, there is nothing actively under way right now. As I've alluded to above, other higher prio things came up first.

    As for 2023 being still in beta: Unity's Version numbers are based on the year the first version of the tech stream releases that turns into the LTS eventually. I.e. what some other software's version of 2024-LTS-beta is, that's Unity's 2023.x so it being still in beta is perfectly normal (tm) vor our versioning and release schedule.
     
  18. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,026
    This is disappointing precisely because almost all iOS and iPadOS games, and all but the best Macs, are primarily GPU constrained. That's where we, as creatives making for these devices, need the most insights so as to balance performance and aesthetics/detail/effects.
     
  19. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,140
    I'd also prefer to do all higher prio work at once but thats sadly not how it works. So XCode Instruments is still your best bet there.

    As for this thread, in the very first screenshot I see a first spike on the CPU, that seems unrelated to it waiting for the GPU, before the GPU starts spiking up. Given it's color and everything else discussed here, it's probably coming from the Editor Loop. So if you switch the target from Playmode to Editor to unpack what's happening in the Editor Loop, that spike might give an indication of what GPU work is getting kicked off from the main thread there that leads to the spike. (Might need Deep Profiling but try both)