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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Asking some advice about spikes seen in profiler

Discussion in 'Editor & General Support' started by Polkatuba, Sep 18, 2015.

  1. Polkatuba

    Polkatuba

    Joined:
    Oct 31, 2014
    Posts:
    79
    Greetings,

    When I run my scene with profiler, I can see occasional spikes in "Material.SetPassUncached". When the spikes happen, the game stutters. I have been trying to search what this "SetPassUncached" means but found zero results. Is there any knowledgeable person who could give some advice where to look for resolution?

    setpassuncached.jpg
    Thanks
     
    Tethys likes this.
  2. pixpusher2

    pixpusher2

    Joined:
    Oct 30, 2013
    Posts:
    121
    I'm encountering similar issue. It happens when a skinned mesh comes into view. Strangely I doesn't spike all the time, but it's very noticeable when it does. Anyone knows how to fix this? Thanks

    spikes.jpg
     
  3. Andres-Fernandez

    Andres-Fernandez

    Joined:
    Feb 4, 2013
    Posts:
    57
    Big bump here...

    In my case it happens in a scene with many GameObjects (4900+). And if I try to switch their material every frame, it takes nearly 20 ms.
     
  4. Polkatuba

    Polkatuba

    Joined:
    Oct 31, 2014
    Posts:
    79
    It's getting obvious that nobody seems to know about this?
     
  5. CrunchingKoalas

    CrunchingKoalas

    Joined:
    Mar 29, 2011
    Posts:
    51
    Hey there!

    I'm randomly getting a pretty big spike caused by Material.SetPassUncached - has anybody also encountered it while using Unity 5.2.2p2? Maybe someone knows what causes it? Any tips will be appreciated.

    Thanks!
    Tom
     
  6. DarkArts-Studios

    DarkArts-Studios

    Joined:
    May 2, 2013
    Posts:
    389
    I'm getting these heavy spikes as well, using Unity 5.3.0f2

    Anyone?

     
  7. CL_HG

    CL_HG

    Joined:
    Mar 5, 2014
    Posts:
    6
    Same here.. I'm using Unity 5.3.0f4.. But this came very sudden.. I haven't have that issue yesterday evening when I closed Unity. Today I opened Unity and run my scene without any changes and this spikes appear..
    Somehow Unity does this strange things only if you are close to the release deadline.. ;)
     
  8. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,171
    Are you all overbooking your GPU memory? Have you tried lowering your texture sizes in the quality settings?
     
  9. kierand

    kierand

    Joined:
    Sep 22, 2014
    Posts:
    32
    We have also just started seeing this on 5.2.2p3, similar to CL_HG just before a deadline (coincidence?).

    It can seemingly happen fairly randomly when first rendering a new object that has not been rendered before. It seems like Unity is swapping something in/out. I presume that there is something with a finite pool size internally in Unity that we are managing to exhaust.
     
  10. Polkatuba

    Polkatuba

    Joined:
    Oct 31, 2014
    Posts:
    79
    I'm curious if anyone have noticed these spikes in the build? I wonder if it is occurring only in the editor.
     
  11. CL_HG

    CL_HG

    Joined:
    Mar 5, 2014
    Posts:
    6
    I haven't tested it in depth yet, but for me preloading the shaders seems to fix it so far.
     
  12. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    We are also experiencing this issue since Unity 5.something heh. We're not sure which update it may have started it but have been experiencing it for months on end and haven't been able to sort it (on Unity 5.3.4 now). Same error in profiler on a bunch of materials, around 70%+ on Total and Self and causing awful lag spikes (120+ Time MS).
     
    Last edited: Mar 23, 2016
  13. drolak

    drolak

    Joined:
    Jan 21, 2014
    Posts:
    49
    Same here on 5.3.5p5 (5.3.5 the same). Found anything guys?
    Thought that it was compiling the shader, but it's like in that screenshot - the spike is inside the SetPassUncached.
     
  14. _MGB_

    _MGB_

    Joined:
    Apr 24, 2010
    Posts:
    74
    Also seeing this, v5.4.0f3 :( :(
     
  15. Exbleative

    Exbleative

    Joined:
    Jan 26, 2014
    Posts:
    216
    I'm having this too, and I'm also yet to fix the fact I'm over my shader keyword limit. I wonder if anyone else is hitting the keyword limit that is getting this problem? Maybe Unity is juggling keywords or something on a new material/shader load, I don't know? I'm getting 1000ms spikes!
     
  16. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    Same here and we have hit our shader limit and cannot seem to fix it. Lots of people having issues with this shader limit problem, really wish Unity would realize how important of an issue it is and bring it to the front of their schedule of issues/workarounds to address.
     
  17. daisySa

    daisySa

    Joined:
    Dec 29, 2011
    Posts:
    341
    @Aras has said that the shader limit will be increased to 256 in 5.4.1.
     
    Tethys likes this.
  18. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    Oh thanks I missed that, wonderful news!
     
  19. daisySa

    daisySa

    Joined:
    Dec 29, 2011
    Posts:
    341
  20. Polkatuba

    Polkatuba

    Joined:
    Oct 31, 2014
    Posts:
    79
    Sorry, I'm inexperienced with the shader keyword limit issue. How do I know if this is affecting my project? Although I'm doubtful about it, as I'm only using Unity's built in shaders.
     
  21. Tethys

    Tethys

    Joined:
    Jul 2, 2012
    Posts:
    672
    You would be getting error messages about reaching the shader keyword limit. If you're using only default shaders then no, it's not possible for you to be having this issue so no worries.
     
  22. Exbleative

    Exbleative

    Joined:
    Jan 26, 2014
    Posts:
    216
    I'm still getting this issue despite having fixed my shader keyword limit issues.
     
  23. vessen

    vessen

    Joined:
    Sep 29, 2016
    Posts:
    5
    Hi all! Sorry for bad English :)
    I had a similar problem in a system with two displays. And even the work build crash. It helped off the secondary display.

    I found quite simply. Now it was in the error log:
    http://prntscr.com/cnnx23

    This error log without Crash.
    But in the old logs were present Crash.
    It seems that there is some conflict.

    Videocard NVIDIA GTX750ti. Unity 5.4.1

    And to go from 5.3.5 to 5.4.1 was observed only with the situation crash build.
     
  24. Beloudest

    Beloudest

    Joined:
    Mar 13, 2015
    Posts:
    245
    I also have this Profiler mountain of an issue... I noticed it seems to point to the Specular Shader.
     
  25. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    592
    I'm having this problem as well. It's really noticeable during gameplay.

    How do we raise this up into the "issue tracker"? Seems like enough people are having this problem for Unity to warrant a look.

    https://issuetracker.unity3d.com/
     
  26. yuheng0104

    yuheng0104

    Joined:
    Aug 22, 2017
    Posts:
    3
    having this problem as well!!5.4.2f2 any know how to solve this problem
     
  27. yuheng0104

    yuheng0104

    Joined:
    Aug 22, 2017
    Posts:
    3
    hi! do you know how to resolve this problem?plz contact me thanks , 312128364@qq.com
     
  28. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,593
    Would love to know what this is, its using 7% of my total game. unity 2018.
     
  29. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,593
    happening again today, sometimes its fine somethimes its really slow.
     
    mirasrael likes this.
  30. leozzyzheng2

    leozzyzheng2

    Joined:
    Jul 2, 2021
    Posts:
    44
    I found the solution, on some platforms(for example DX11 on windows), Unity will cache material's shader pass, but it has some requirements to your shader code.

    I my case, I type a Texture named "sampler2D _WindNoiseTex", but the real one in properties is named WindNoiseTex, no underline at beginning, so Unity can't cache this shader pass and create it everyframe, that's what you see as "material.setpasscachemissed" in Profiler.

    After I fix the typos, "material.setpasscachemissed" gones.
    I don't know the full requirements for the cache, so you might check all your params in shader code to make sure they are in properties or set by material by code(not sure the second suggestion is ture).

    P.S. I can't find this profiler marker on Android, the cache might not exist in mobile device, so it won't injure the performance on those platforms I guess.
     
    nevebraymok likes this.
  31. nevebraymok

    nevebraymok

    Joined:
    Mar 18, 2020
    Posts:
    1
    Thanks! It worked for me!