Search Unity

WaitingForJob (not related to occlusion culling)

Discussion in 'UGUI & TextMesh Pro' started by dburden1, Oct 26, 2015.

  1. dburden1

    dburden1

    Joined:
    Jan 29, 2015
    Posts:
    19
    Ever since 5.2 came out, we have been getting enormous spikes (like 40ms) every second or two from what the profiler is calling "WaitingForJob." I've seen people asking about this before, but they always report seeing the WaitingForJob item underneath the Camera.Render and Culling. This is not the case for us. This WaitingForJob is a root-level entry in the list, totally separate from the WaitingForJob that occlusion culling shows (and we're not even using built-in occlusion culling at all). These spikes go away completely when we disable our GUI, and, from what I understand, significant changes were made to UGUI between 5.1 and 5.2.

    We can confirm that this WaitingForJob spike does not ever happen to us on 5.1, but it's a regular problem for us in 5.2. The WaitingForJob spikes used to be every frame, making the game (and editor) completely unusable. We were only recently able to update everyone to 5.2 because we found a workaround that makes the spikes only happen every few seconds.

    Has anyone experienced this? We couldn't find anything on the issue tracker either. I've attached a screenshot of our profiler. All the other purple spikes you see are also WaitingForJob spikes.

    We're on 5.2.2p1

    Capture.PNG
     
  2. jcredible

    jcredible

    Joined:
    Dec 4, 2012
    Posts:
    24
    Yes, I'm noticing this as well. I was assuming that it had something to do with the new way Unity was batching but it's less than ideal.. @phil-Unity maybe can comment?
     
  3. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Huh personally i've not seen this before. i can confirm that in 5.2 we jobified the UI batching. I'm not sure why that would be a root item as it should be under a CanvasBuildBatch entry if it was for the UI (unless the profiler is doing something wrong).

    @dburden1 what did you do to make it be only every second maybe it will tell me more about your project so i can figure out what might cause this.
     
  4. dburden1

    dburden1

    Joined:
    Jan 29, 2015
    Posts:
    19
    Well, something I noticed is that the WaitingForJob is only root-level when the Canvas is rendering to a Camera. If it's in screen overlay mode, then the WaitingForJob spike appears under Canvas.RenderOverlays.

    We did two things that got the spike to only happen every few seconds:
    1. We implemented our own sort of "occlusion culling" for our UI, in which our UI elements completely disable their own GameObject hierarchies when not in use. This was done for general performance considerations while we were still on 5.1, but it had a side effect of reducing the frequency of our WaitingForJob spikes in 5.2.
    2. After our aforementioned optimizations, we would still experience every-frame spikes when a particular Image was enabled and being rendered. We had an Image that was scaled to something like 10000x10000 px. Scaling this down to 2000x2000 px fixed that particular every-frame spiking. The 10000x10000 px Image size was overkill just because those were the numbers typed in, and it didn't seem to have any performance impact at all on 5.1.
    It's quite possible that the optimizations we made were simply disabling that large Image for the majority of the game time, making it seem like the optimization itself resolved the issue. However, after scaling that Image down (and combing through our UI to make sure we didn't have any more), we still get spikes, but they're just every few seconds now.

    You can repro the large Image issue fairly easily by creating a Canvas, adding an image, setting it to stretch both directions, enter in -5000 for the left top right and bottom values, then add a new Button GameObject. But then, the strange trick here is to mouse over and/or click on the button. When doing that, you should see the spikes appear in the profiler. I can submit a bug report with a repro for this if necessary. However, it seems like that particular cause of spiking isn't the cause of our other intermittent spikes, since we are fairly certain we don't have any remaining over-scaled Images.
     
    Last edited: Oct 27, 2015
  5. AverageProg

    AverageProg

    Joined:
    Jun 25, 2015
    Posts:
    38
    getting the same thing, although it happens only when my scroll rect moves (or a child updates).

    Scroll rect performance was very bad to begin with, but it's not conceivable that a scroll rect takes up 7ms of cpu time just to build the batch, and another 2ms to actually move the panel, and to add insult to injury you also have those nice 30-40 ms spikes so that you can't even achieve a low fps but steady movement

    So then the producer comes to me and asks why their achievement list is so bad, well I generally point them to unity's webpage and tell them to ask you guys.

    Oh can you notice the frustration in the way I wrote this useless post?
     
  6. dburden1

    dburden1

    Joined:
    Jan 29, 2015
    Posts:
    19
    We have had pretty bad ScrollRect performance as well, although I'm not sure the problems with the WaitingForJob spikes and the ScrollRect performance are related in our particular case (but I'm not totally ruling it out either). I was going to make a separate thread regarding ScrollRect performance, but it would be nice if fixing the WaitingForJob issue fixed the ScrollRect performance too. I'll edit this post with the link if/when I make another thread.
     
  7. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Hmm ok could one of you possibly submit a bug report so i can take a look using your use case?
     
  8. dburden1

    dburden1

    Joined:
    Jan 29, 2015
    Posts:
    19
    For the WaitingForJob spikes or the ScrollRect performance?
     
  9. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    just one bug mention both i think would be ok.
     
  10. jcredible

    jcredible

    Joined:
    Dec 4, 2012
    Posts:
    24
    I'm not having the ScrollRect performance bug but I went ahead and filed a bug for the WaitingForJob issue. I'm still not 100% sure if it's a performance issue but it's worth looking into. I'll edit with a case number soon. Please let me know if you have any questions.

    EDIT: case # is 741295
     
    Last edited: Nov 1, 2015
  11. AwDogsGo2Heaven

    AwDogsGo2Heaven

    Joined:
    Jan 17, 2014
    Posts:
    102
  12. AwDogsGo2Heaven

    AwDogsGo2Heaven

    Joined:
    Jan 17, 2014
    Posts:
    102
    jcredible, have you had any progress in this yet?
     
  13. pertsa

    pertsa

    Joined:
    Jul 3, 2013
    Posts:
    15
    Just to accompany the above comments, here are the WaitingForJob problem that I am experiencing with 5.2.3f1.

    All the three spikes here are "WaitingForJob"s.

    This happens all the time in a menu scene with lots of RectTransforms. In the actual gameplay (with only few RectTransforms) these happen very rarely. So somehow this is linked to UI elements, but not necessarily to SrollRects.

    upload_2015-12-1_10-18-43.png
     
  14. jcredible

    jcredible

    Joined:
    Dec 4, 2012
    Posts:
    24
    @pertsa if you can reproduce this, can you open a bug?

    I ran my bug report project against 5.2.3 a few nights ago and I didn't really notice any issues (whereas before I was noticing WaitingForJobs very often). I'll do another test tonight.
     
  15. Democide

    Democide

    Joined:
    Jan 29, 2013
    Posts:
    315
    I'm having the same issue. About every 2 seconds there's a spike.
     
  16. bellatesla

    bellatesla

    Joined:
    Mar 28, 2015
    Posts:
    3
    Having the same issue still in 5.3 . I've been trying to track this down and can't seem to find a solution. All the spikes are the same about 20ms. waitforjob.jpg
     
  17. dburden1

    dburden1

    Joined:
    Jan 29, 2015
    Posts:
    19
    We never did find a solution either.
     
  18. holliebuckets

    holliebuckets

    Moderator

    Joined:
    Oct 23, 2014
    Posts:
    496
    Does anyone have a bug number?
    When running Unity choose Help->Report a Bug in the menu.
    I can take a look into the issue for you, but I need a bug number.
     
  19. dburden1

    dburden1

    Joined:
    Jan 29, 2015
    Posts:
    19
     
  20. holliebuckets

    holliebuckets

    Moderator

    Joined:
    Oct 23, 2014
    Posts:
    496
    Thank you so much @dburden1 I'm looking into your bug now. Just out of curiosity, are you still on 5.2.2f1?
     
  21. dburden1

    dburden1

    Joined:
    Jan 29, 2015
    Posts:
    19
    I'm currently on 5.3.2p3.
     
    holliebuckets likes this.
  22. holliebuckets

    holliebuckets

    Moderator

    Joined:
    Oct 23, 2014
    Posts:
    496
    Do you have the same issue? and would you be able to submit another bug report? If you do, post the second case number and I'll send them both at the same time. I can at least get you an update.
     
  23. cdytoby

    cdytoby

    Joined:
    Nov 19, 2014
    Posts:
    181
    The issue is still there, I updated to Unity 5.4.0f3 and I have this issue.
    I don't have it in 5.3.
     
  24. cherrypick-games

    cherrypick-games

    Joined:
    Jan 30, 2015
    Posts:
    2
    Same here. After updating from 5.3.5f1 to 5.4.0f1 we are getting some enormous lag spikes (over 7000ms). Usually when some UI elements are hidden.

    WaitingForJob
    --Canvas.SortJob
    ----Canvas.Sort

    Canvas is in Overlay mode and sometimes there are elements which are dynamically added/removed from hierarchy or transform.SetAsLastSibling() is used.
     
  25. NeoFlashGI

    NeoFlashGI

    Joined:
    Jul 15, 2016
    Posts:
    1
    Very similiar bug in my project, on 5.4.0f3. SOmetimes only on android (can't catch this in editor) game freezes for 10-40 seconds. Catched in profiler and i see this Canvas.Sort for more then 10 seconds. bug1.jpg bug2.jpg bug3.jpg
     
  26. VicariousAlex

    VicariousAlex

    Joined:
    Aug 3, 2015
    Posts:
    5
    I'm getting something really similar on Android when I'm scrolling. I'm on 5.3.5f1
     
  27. jdb1218

    jdb1218

    Joined:
    Feb 3, 2016
    Posts:
    2
    I'm on 5.4.0f3 and seeing the same issue when scrolling. Huge spikes under "WaitingforJob".
     
  28. ortin

    ortin

    Joined:
    Jan 13, 2013
    Posts:
    221
    Has anyone reported a bug against 5.4?
     
  29. DiscoJustice

    DiscoJustice

    Joined:
    Aug 21, 2013
    Posts:
    15
    I've been having this issue since 5.2. My bug reports went unanswered, although as of 5.3.5 the test case I submitted no longer showed the issue, although it's still happening in my game.

    Spent the evening figuring out a new test case, and have updated my bug. No one ever got back to me previously, but hopefully someone will take a look at the update? It's bug 743008.
     
  30. Frima

    Frima

    Joined:
    Jan 26, 2016
    Posts:
    52
    waitingForJob1.jpg waitingForJob2.jpg waitingForJob3.jpg Hi, I've been experiencing this issue too. I'm on 5.4.1f1, running at 100+fps on xbox one. I have these unexpected lag spikes at random moments. I have absolutely no clue about the cause.


    Looking forward a fix asap.. thank you!
     
  31. AlexisTerraf

    AlexisTerraf

    Joined:
    Oct 31, 2016
    Posts:
    6
    Hi all, I would like to confirm that I am encountering this bug as well.
     
  32. DrKucho

    DrKucho

    Joined:
    Oct 14, 2013
    Posts:
    140
    same here, just switched to unity 5.4 and got the purple spikes for first time.
     
  33. ammarvohra

    ammarvohra

    Joined:
    Jan 24, 2016
    Posts:
    10
    Upgrading to Unity 5.5 was the best solution I've got. :)
     
  34. 0808508

    0808508

    Joined:
    Oct 13, 2016
    Posts:
    1
    Having the same issue in 5.4.0.f3 anyone has solved the problem???
     
  35. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    705
    Still seeing this in 2019.3! I suspect this means I'm trying to run too many jobs at once but still pretty inconsistent behaviour for something to block the main thread and can stall at any point one of my jobs needs to run

    Screenshot_1.png
     
  36. zhutianlun810

    zhutianlun810

    Joined:
    Sep 17, 2017
    Posts:
    171
    Still seeing this 2019.4.13. I added some log in "Canvas.PrepareSubBatches" and found that there is a huge gap between my logs. However, I am 100% pretty sure there is no code between my logs. What was the engine doing at that time? Snipaste_2021-03-15_15-11-51.png Snipaste_2021-03-15_15-12-13.png
     
    Last edited: Mar 15, 2021