Search Unity

Occlusion culling CPU spike in profiler

Discussion in 'Editor & General Support' started by Arkensis, Mar 30, 2015.

  1. Rycons

    Rycons

    Joined:
    Nov 23, 2013
    Posts:
    31
    Would it be possible to get some support from Unity on this issue? I would be very grateful if someone can take a look at this since we've been plagued with Physics. Processing and Culling spikes for months on end now.
     
  2. Olafson

    Olafson

    Joined:
    Aug 7, 2012
    Posts:
    251
    Yes. Our game is set to release very soon, and with the current spikes, we can not release it...
     
  3. McGravity

    McGravity

    Joined:
    Nov 2, 2013
    Posts:
    43
    As @blunzn said, there are two issues regarding the CPU peaks problem. One of them seems to be fixed in 5.4. That means apparently you have to wait, as 5.4 will be released in a month. https://unity3d.com/unity/roadmap

    One thing you could try is to use an older Unity version ( < 5.2 ) to build your project if you can't wait for a month.

    Btw.: I'm having the same problem with the CPU peaks.
     
  4. Rycons

    Rycons

    Joined:
    Nov 23, 2013
    Posts:
    31
    @McGravity Back porting is sadly not an option for us and I'm quite sure Unity 5.4 will have it's own fair share of problems.
     
  5. GroundCombo

    GroundCombo

    Joined:
    Jan 23, 2015
    Posts:
    17
    We also have 500-700ms Culling/WaitingForJob spikes in one of our 2D scenes on an iPad 2; other test devices don't have this problem. I'm using 5.2.4 and can't upgrade to 5.3 because of another bug (https://issuetracker.unity3d.com/issues/fmod-sound-instance-for-resource-error). Strangely, other scenes are perfectly fine - this particular scene has more moving objects than the rest, so maybe that triggered the bug. Any workaround ideas would be appreciated - explicitly disabling SpriteRenderers for offscreen objects didn't help.

    edit: I shuffled objects and their triggers around and wrote a script to activate/deactivate offscreen enemies more aggressively, and the hitching stopped. This should be a good enough workaround for us (knock on wood), but it is a pretty bad bug considering that the scene has less than 30 enemies.
     
    Last edited: Feb 22, 2016
  6. nxtboyIII

    nxtboyIII

    Joined:
    Jun 4, 2015
    Posts:
    218
    I'm having the same issue with the CullAllVisibleLights.
     
    Velo222 likes this.
  7. Alabatross

    Alabatross

    Joined:
    Dec 15, 2012
    Posts:
    223
    Any news on this?
     
  8. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,095
    Anyone did bug reports so Unity is aware of the issue?
     
  9. Olafson

    Olafson

    Joined:
    Aug 7, 2012
    Posts:
    251
    We have exchanged several emails with Unity developers, so they are definitely aware of this. (Although reporting a Bug is not going to hurt) However, they seem to think that it is fixed.

    We might have to wait for 5.4 to get a definitive fix.
     
  10. canaljuegos32

    canaljuegos32

    Joined:
    Jun 29, 2015
    Posts:
    53
    I have the same problem, wonder if is the cause of the little lag spikes i have? even with 150 fps.
     
  11. JD_C4M

    JD_C4M

    Joined:
    Aug 29, 2014
    Posts:
    1
    Same problem here on iPhone/iPad and 5.3.4p5 doesn't seems to fix it.
    We have a release soon and this is a huge problem for us.
     

    Attached Files:

  12. amoraleite

    amoraleite

    Joined:
    Oct 16, 2014
    Posts:
    13
  13. canaljuegos32

    canaljuegos32

    Joined:
    Jun 29, 2015
    Posts:
    53
    I fixed by going back to 5.1.4...
     
  14. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,340
    Add me to the list of people having the same problem. As someone else mentioned "CullAllVisibleLights" is also an issue apparently. I'm ok with upgrading to 5.4 if this fixes the issue.
     
    nxtboyIII likes this.
  15. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    5,751
    also having seemingly high values (in a scene with very few objects) in 5.3.4f1 (android + cardboard)
    upload_2016-6-7_14-13-6.png

    *Disabling 2 particle systems made some difference,
    upload_2016-6-7_14-20-9.png
     
  16. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Same here, without culling I get 60FPS after I bake the culling I get 10-20 FPS. (A big terrain, full of speed trees and speed tree grass). Anyone found any workarounds/ideas? (Unity 5.3.4). Any fix for 5.4 or ...?
     
  17. atsamy

    atsamy

    Joined:
    Feb 28, 2013
    Posts:
    5
    I have the same problem, so i cleared the occlusion culling data and unflagged it from the camera, but still in the profile it shows that it process the culling.
     
  18. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Try the 5.4 beta. I see a considerable performance improvement in that version. I think we're doomed on waiting for 5.4...
     
  19. Morfeuskiev

    Morfeuskiev

    Joined:
    Oct 10, 2013
    Posts:
    122
    The culling have two parts - Frustum Culling and Occlusion culling. Yes i can confirm that Culling technology in Unity 5 is not effective.
    In our game we have problem with performance that our rendering time have drawing in 30-40% and culling 60-70% (Occlusion culling is disable). But we can not disable Frustum culling (object which not visible in camera).

    I believe in Unity 5.4 and it`s new post process effect. But if the miracle will not happen - i can say that unity engine is not for big outdoor game with many dynamic object. (Yes - you known about what i say ;) )
     
  20. Morfeuskiev

    Morfeuskiev

    Joined:
    Oct 10, 2013
    Posts:
    122
    I tried the beta 19. It is very difficult to compile a project that have a several tens GB. But after compile - the performance was worse than in 5.3.5. So this is not big problem, another problem in that many asset not ready for 5.4.
     
  21. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    That too yes. As for the performance, are you sure it was worse than 5.3.5? It was the opposite for me. (Beta 22). With a big 22sq/km of open world map. (of course it was a nightmare optimizing the grass but with some clever workarounds it finally worked at a decent 40fps on a low-medium end video card)
     
  22. Morfeuskiev

    Morfeuskiev

    Joined:
    Oct 10, 2013
    Posts:
    122
    As i say - i tried beta 19. And yes - performance is worse.

    In our game we have world map: 4, 16, 64 and 100 sq. km. We using more than 30 thousand object. Incidentally, most stress for unity give Speedtree.

    We can`t use static batching, because it make our build very large. (one scene after batching can have 1 GB). So i very wait for GPU Instancing. As i try beta 19 - it does not work.
     
    Assembler-Maze likes this.
  23. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    I see, not cool with 30k objects. Interested in this, could you provide me some details?

    Is the terrain tillable? Do you use speedtree for grass? Do you use grid based speedtree visibility for very large maps?
     
    Morfeuskiev likes this.
  24. Morfeuskiev

    Morfeuskiev

    Joined:
    Oct 10, 2013
    Posts:
    122
    @Assembler Maze

    You can download our game now and and see for yourself :)

    We are use large far clip (10k), so in many situation (as example map 8x8 km) we use background landscape with normal map and custom shader. In most case we use one terrain (for performance reason). Yes we use grass unity terrain and grass as Speed tree. So as i say - we use large far clip and need to location looked fully at all distance.
     
    Assembler-Maze likes this.
  25. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    The game looks cool I'll download it for sure. As for the speedtree grass I had the exact same problem. I ended up having a grid system that enables/disables whole patches of speedtree grass based on the user's position. It improved FPS from 20 to 50 (since if distant grass is tested for LOD even if it is completely invisible! Imagine looking 10km in the distance and the grass is still getting 'LOD tested' even if it is miles away)

    I think I'll make a future tech post about that.
     
    Morfeuskiev likes this.
  26. Foxxis

    Foxxis

    Joined:
    Jun 27, 2006
    Posts:
    1,107
    Any news on this issue? We are having it as well in 5.3.x. Curious if/in what way 5.4 makes a difference...?
     
  27. Olafson

    Olafson

    Joined:
    Aug 7, 2012
    Posts:
    251
    I just encountered this in 5.4...
     
  28. deverolirc

    deverolirc

    Joined:
    Jan 19, 2014
    Posts:
    475
    Seriously what is going on with this? We are having this problem too, and cannot find what is causing it.
     
  29. deverolirc

    deverolirc

    Joined:
    Jan 19, 2014
    Posts:
    475
    Also, we are using 5.4.1 p1, can anyone confirm a fix or solution? I believe our problem is having lots of objects in the scene.. Has no one from Unity seen this forum yet? This is making our game unplayable.
     
  30. DrKucho

    DrKucho

    Joined:
    Oct 14, 2013
    Posts:
    140
    same here, i never had these purple spikes... i have tried unity 4 (several versions till last one) then unity 5.2, 5.3... i had other similar spike problems but not related to culling, now on 5.4 they showed up :

    CameraRender.Culling.CullSendEvents.WaitingForJob.WaitingForJob

    upgrading unity is like a box of chocolates, you never know what bug you gonna get...
     
  31. DrKucho

    DrKucho

    Joined:
    Oct 14, 2013
    Posts:
    140
    im reading about this and it could be related to high end CPUs such as i7s , seems to be related to CPU HyperTreading , something that lower CPUs does not have... ? don't know much about this

    i do have a i7

    the question is, do you guys all have HyperThreading CPUs such as i7 or intel Xeon?
     
  32. slake_it

    slake_it

    Joined:
    Aug 2, 2015
    Posts:
    75
    Any updates on this ? I'm having the scene culling issue with unity 5.2
     
  33. phasiclabs

    phasiclabs

    Joined:
    Nov 13, 2013
    Posts:
    126
    I've just tracked down big stalls in our game (on consoles and Windows 7) to this - we are using Unity 5.4.1p2 on this project. It's CullSendEvents waiting for jobs, so I guess it isn't fixed in 5.4.
     
  34. DrKucho

    DrKucho

    Joined:
    Oct 14, 2013
    Posts:
    140
    hello? anybody there? anyone else with an i7? thanks
     
  35. DrKucho

    DrKucho

    Joined:
    Oct 14, 2013
    Posts:
    140
    i used a software on osx to limit the use of the processor cores, and tested my game, the spikes disappeared when using just one core , of course the overall performance was also worse , unity takes too much time for rendering for example, but it was stable , not random like the waiting for job spikes...

    does this mean anything? i don't know , maybe if you guys post here which processor and how many cores you have ...
     
  36. phasiclabs

    phasiclabs

    Joined:
    Nov 13, 2013
    Posts:
    126
    My experience of this has mainly been on XBox One - I've just made it go away however by disabling Experimental Graphics Jobs - I suspect Unity's job system isn't scheduling threaded jobs particularly well and they are all getting in each other's way.
     
  37. Section-One

    Section-One

    Joined:
    Sep 8, 2014
    Posts:
    80
    Same exact problem. WaitingForJob under CullAllVisibleLights takes 40% of my frame time.
    But only on Android. On PC it's ok.
     
  38. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,095
    Unity support is available from within the Unity editor. Go to window and report a bug. They will then read it and assess it and if necessary reply to you.
     
  39. Threepwood

    Threepwood

    Joined:
    Jul 23, 2009
    Posts:
    87
    Interesting, seeing the same thing. iMac, i7, and the game uses multiple threads/cores, constantly. I tend to get massive spikes every 10-12 seconds that spike for 80-100ms. None of them are game function related and all seem to be system related. Discounting the odd spike for garbage collection, which is expected. I never noticed this until I profiled outside of the editor.

    On Unity 5.5.0p2
     

    Attached Files:

    slake_it likes this.
  40. KingLlama

    KingLlama

    Joined:
    Jul 18, 2015
    Posts:
    180
    So i'm running into issues with culling and the reflectionProbes.update. Its happening alot and consistently.
     
  41. kk99

    kk99

    Joined:
    Nov 5, 2013
    Posts:
    77

    I have been having the same prbolem since I moved to Unity 5.5.1

    This did the trick for me.


    When you are baking light enable Shadows (doesnt matter if soft or hard shadows) (I just assume you need shadows) when you are done disable the shadows for all realtime and mixed lights.

    And somehow maybe this is just placebo but deactivate all kind of lights that are just baking.

    I fee like this does improve the FPS little bit too

    upload_2017-2-13_4-11-9.png
     
  42. DrKucho

    DrKucho

    Joined:
    Oct 14, 2013
    Posts:
    140
    i've sent one bug report including simple project that causes the issue on december 2016
    https://fogbugz.unity3d.com/default.asp?862453_j28oscml1r4t61kr
    got no emails from unity, no nothing, case is still open with no changes since the first day.
    today i have tried unity 5.5.1p4 with the same test project and the spikes are the same, i've sent a new bug report with the same project but this time pointing that it also happens in the newer version (they say that they priorize on bugs of the last version)... when i send the first bug report i did also with the latest version but nothing happened... , hopefully this time we have more luck

    these are my first bug reports so not sure if this behaviour is "normal" , if anyone here have more experience i would appreciate some advice if there is a way to help unity to put more attention on a specific bug report.
     
    KingLlama and Assembler-Maze like this.
  43. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,095
    If it's still an issue, please submit another case. Cases with substantial text and attached repro file will get looked at every time, while cases without repro and without text will often just get just used for statistical data about the issue, like hardware or something.

    It may be they can't reply because they can't resolve it or it's still an ongoing bug.
     
  44. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    Really? It didn't helped with this other problem: https://forum.unity3d.com/threads/lod-group-baked-lighting-how-to-use.349103/

    Tons of text + examples.
     
  45. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,095
    You mean to say it didn't get the response people expected. But, Unity do use bug reports, and do respond. This is not a cast iron 100% gold star platinum guarantee though?
     
  46. Assembler-Maze

    Assembler-Maze

    Joined:
    Jan 6, 2016
    Posts:
    630
    They responded to many issues quite fast (i guess the ones that are relatively easy to fix), but not this one. Sometimes they respond positively, sometimes they respond negatively, sometimes they don't respond at all.
     
  47. DrKucho

    DrKucho

    Joined:
    Oct 14, 2013
    Posts:
    140
    i just notices that, after sending my second bug report, i didn't receive an email from bugs@unity.com like when i sent the first one, i remember a pop up window saying that the report was sent, but no email , wondering if they really received it ... :-(
     
  48. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,095
    It may take a while, check spam folder as well :)
     
  49. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,670
    Just adding my note here that I see the problem also. I'm on a mac with Unity 5.5.0f3, there isn't much going on in my scene - scripts are pretty constant at 1-2ms and rendering is nothing major (minor 2d, not many objects, no user input). And just randomly I'll get these same spikes up to around 15-20ms out of the blue, and it all revolves around the culling of dynamic objects, or a least, the wait for task part.
     
  50. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,042
    Same here, in 5.5.1 on Mac 10.11.5. Not using OC but getting the same spikes as imaginaryhuman describes.
     
unityunity