Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question FPS spikes - Semaphore.WaitForSignal - GPU

Discussion in 'General Graphics' started by Etamain, Jun 8, 2021.

  1. Etamain

    Etamain

    Joined:
    May 7, 2021
    Posts:
    4
    Hello, I have a very very annoying problem, since a few weeks each time I use Unity3D, I have this problem:

    FPS spikes at more or less regular intervals, caused by "Semaphore.WaitForSignal" according to the Profiler, this call preceded (1-2 frames before) by a spike in the GPU Usage according to the Profiler, caused by "Other".

    I can't see at all where this can come from, my Unity3D or my computer?
    What is present in the "Other" category of "GPU Usage" in the Profiler?

    When going on PlayMode, i'm around 300 FPS, after 10 to 20 seconds, the problem appears.

    Here is the information related to Unity and my laptop:

    - Unity version: 2021.1.10f1 (same problem on the 4-5 versions before this one)
    - Two graphics cards: Intel HD Graphics 630 | NVIDIA GeForce GTX 1050
    - Processor: Intel core i5 7300HQ

    The latest drivers are installed.
    Any project creates the same problem (3D, 2D, Android, Windows...) [Empty or full]
    The following screenshots are from the Profiler.

    [Frame on the CPU Usage]
    upload_2021-6-8_18-38-47.png

    [2 Frames Ealier on the GPU Usage]
    upload_2021-6-8_18-49-58.png
     
    Last edited: Jun 8, 2021
  2. tvirolai

    tvirolai

    Unity Technologies

    Joined:
    Jan 13, 2020
    Posts:
    79
    I do agree it's confusing. I had exactly the same issue myself when dealing with a bug.

    Long story short: That's almost certainly the editor itself. When the editor issues draws to display UI and whatnot it goes through the same GPU submission as everything else. But it's not visible in the play mode profiling view. From that perspective it just looks as if one has to wait for the GPU.

    That Semaphore.WaitForSignal under the WaitForPresent means that it's basically just waiting for the submission thread to actually finish presenting the previous frame (or N frames behind to be more exact) until it can start doing more. If you'd enable vsync the wait would look pretty much identical.
     
  3. Etamain

    Etamain

    Joined:
    May 7, 2021
    Posts:
    4
    So, it would come from the editor? Is there a solution? Because it's very difficult for me to develop a game with such a low FPS (and therefore freezes) almost permanently :( ...
     
  4. tvirolai

    tvirolai

    Unity Technologies

    Joined:
    Jan 13, 2020
    Posts:
    79
    You could try profiling on standalone player. One can build and attach a profiler relatively easily from the editor UI.

    Though admittedly 300ms spikes in GPU usage are definitely not expected. They're way too high. Does this happen only with one of the graphics cards? You can specify the GPU used in windows 10 graphics settings "Graphics performance preference".
     
  5. Etamain

    Etamain

    Joined:
    May 7, 2021
    Posts:
    4
    I already tried to build in Standalone, nothing changes, same for using a specific graphics card, no difference, my computer (or its graphics cards) may be sweating?
     
  6. jitterware

    jitterware

    Joined:
    Mar 31, 2018
    Posts:
    4
    I'm having exactly the same problem. I was using 2021.3.1f1 with no problems then I upgraded to 2021.3.26f1 because I needed to use an upgrade in the Input System package and the problem appeared. Just like you my frame rate spikes to 295 ms. However, I only see this approximately once every 2 minutes. In my case the game is working fine and running at a frame rate of about 10-16ms, then randomly it will spike to 295 ms for 1 or 2 frames and go right back to 10-16 ms. This happens whether there is a lot of enemy AI on the screen or none. So it tells me its not my game eating up too many resources.

    You can see the spike here.
    upload_2023-6-5_21-18-47.png

    In my case the Semaphore.WaitForSignal is the result of the EnlightenWorker as shown below

    upload_2023-6-5_21-20-7.png

    Like I said, this wasn't a problem with earlier versions and I definitely didn't change anything in my game that would explain this sudden drop in the frame rate. The game was working for almost a year before I upgraded. Unity has cursed me every time I upgrade to a newer version, even when upgrading to the LTS versions. But I needed the new rebinding system in the Input System, so I had no choice. Can I shut this enlighten worker off?
     
    Allan-MacDonald likes this.