Search Unity

Question Rendering time increases.Maybe ' Semaphore.WaitForSignal' and 'Gfx.WaitForPresentOnGfxThread'

Discussion in 'General Graphics' started by j118089, Nov 14, 2022.

  1. j118089

    j118089

    Joined:
    Apr 11, 2022
    Posts:
    4
    I wrote a program to change the transparency of a simple Image Object. I thought it was working fine, but it would occasionally stop drawing. I checked with Profiler and found that there was a long (27.05ms) rendering wait time.
    This is a very serious problem in my program.
    The Unity version is 2021.3.11f1 and I use URP and FSP for rendering.
    However, I also confirmed this problem with Unity 2020.3.28f1, default rendering.
    unity forum 1114.png
    Hope someone has an answer to this problem.

    Sincerely,
     
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,060
    This usually means the GPU is at it's maximum.
    Does this spike occur when doing something else as well? Maybe adjusting the material?
     
  3. j118089

    j118089

    Joined:
    Apr 11, 2022
    Posts:
    4
    Thanks for your reply.

    I use Image Object. I have changed that object Color.a parameter of it in every frame.
    I certainly agree that the GPU is overburdened, as you noted.

    However, this delay does not occur every frame. If this were the case, I thought there must be a solution.
    Sorry for the lack of words in the explanation.

    I would like to get it to work on a 240hz display somehow. I thought maybe it was because I had declared new Color in the FixedUpdate function to change Color.a, so I commented it out. But the result did not change.
    Deleting the Image object did not change the profiler result.

    Maybe I am making some elementary mistake. If you have any other ideas, please let me know.

    Regards,
     
  4. c0d3_m0nk3y

    c0d3_m0nk3y

    Joined:
    Oct 21, 2021
    Posts:
    675
    Select the GPU Usage module (second row from the top), scrub to the long frame and look at the details. It should show you what took so long.
     
  5. j118089

    j118089

    Joined:
    Apr 11, 2022
    Posts:
    4
    Thanks reply.
    When I checked GPU Usage module, the result is shown in the figure below. Where is the problem in this I could not find.

    unity forum 1115_2.png

    Next I looked at CPU Usage for the same timing.
    The result looked like this, and I was curious about the "71 instances over 10 threads" in "Semaphore.WaitForSignal".

    unity forum 1115.png

    This problem occurs even if I turn off Canvas and stop all homebrew scripts. Do you have any idea what might be causing this?

    Regards,
     
  6. j118089

    j118089

    Joined:
    Apr 11, 2022
    Posts:
    4
    add (e.g. annex)

    unity forum 1115_3.png

    EnlightenWorker is most likely the problem.
    However, I do not know how to fix this.
    Please help me.
     
  7. c0d3_m0nk3y

    c0d3_m0nk3y

    Joined:
    Oct 21, 2021
    Posts:
    675
    It's usually not a problem when a worker thread waits for a signal for a long time. It's just a problem when the main thread does it. Worker threads often wait for a signal when there is no work to do.

    It is strange that the GPU frame time is much shorter in the detail window than the overall GPU total time. It's hard to say what this could be. I've had a case like this once where the game turned out to be PCI bandwidth bound but it's not very likely that this is your problem.

    I'd try using a system profiler in this case like NSight Systems. That will show you what's going on in the entire system, not just CPU and GPU:
    https://developer.nvidia.com/nsight-systems

    Also, always profile with a standalone build. There is a lot of editor code that can cause hitches when you run the game in the editor.
     
  8. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833