Search Unity

semaphore.waitforsignal causing huge spikes in profiler. Restarting Unity fixes the problem

Discussion in 'Editor & General Support' started by jlanisdev, Jul 10, 2020.

  1. jlanisdev

    jlanisdev

    Joined:
    Jan 18, 2016
    Posts:
    76
    Working on iOS platform / 2018 mac mini and recently upgraded to the latest 2019.4 LTS. I was previous on 2018.4 LTS.

    Ever since updating Unity, play mode has been extremely slow. The unusual thing is that restarting Unity fixes the problem every single time, and then eventually the problem will reoccur. It's difficult to say exactly what causes the issue to reoccur, but I've noticed it happens often after switching my repo to a different commit or pulling changes. It seems that every time that happens, I need to open the project in Unity & then restart Unity before play mode returns to normal behavior.

    The issue appears to be either Semaphore.WaitForSignal or EditorLoop (see attached image from profiler). The fact that restarting Unity fixes the issue, and that it never occurred before upgrading to 2019.4, makes me assume this is most likely a bug. Note that I already have VSync disabled.

    I've also tried profiling the GPU but all I get is a yellow warning icon in the profiler. It says "GPU profiling is not supported when using Metal". I've tried disabling Metal and still get the same message.
     

    Attached Files:

    Last edited: Jul 11, 2020
  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,455
    Hi,

    Could you please provide a screenshot where the render thread, which contains the Semaphore that the main thread is waiting on, is fully visible? Ideally also for the previous frame because that likely started work on it that hasn't finished in time.

    Also could you additionally try profiling the editor while you're in Playmode?
    Easiest way to do so is is with the Profiler set to Deep Profiling and targeting Editor instead of Playmode, you can then either start recording via the record button of the window, before closing it, or via the Profiler recording shortcuts F9 while still in Editmode.
    Run Playmode for a bit, then hit F9 again to stop the profiler and open its window again.
     
  3. jlanisdev

    jlanisdev

    Joined:
    Jan 18, 2016
    Posts:
    76
    @MartinTilo see attached screenshots. Two were targeting Playmode, and the other two were targeting Editor.
     

    Attached Files:

  4. jlanisdev

    jlanisdev

    Joined:
    Jan 18, 2016
    Posts:
    76
    @MartinTilo I've noticed that the issue seems to occur whenever one of our .blend files in the project has been updated, or after importing an asset.
     
    Last edited: Jul 25, 2020
  5. jlanisdev

    jlanisdev

    Joined:
    Jan 18, 2016
    Posts:
    76
    @MartinTilo This is what it looks like after restarting Unity
     

    Attached Files: