Search Unity

Why are Canvas.BuildBatch() spikes still occuring ?

Discussion in 'UGUI & TextMesh Pro' started by Jbs_GameZone, Apr 24, 2019.

  1. Jbs_GameZone

    Jbs_GameZone

    Joined:
    Dec 14, 2018
    Posts:
    118
    I'm developing a 3D car game and am encountering Canvas.BuildBatch() huge spikes as seen here :

    Screenshot 2019-04-24 at 14.33.03.png

    I've already created a separate canvas that holds a tiny fraction of the UI gameobjects which act as input controls (steering / acceleration) so that, if dirty, the canvas rebuild will affect only them. At any given point there should be less than 10 objects enabled. Here is the hierarchy

    canvas4.png

    In the above scenario I've eliminated almost everything from the screen leaving just 5 buttons (acceleration, brake and 3 buttons on top-left corner, none of which change their position, rotation or scale, so they shouldn't mark the canvas dirty at all) but even so the spikes still occur. Below is the screenshot from the game

    image1 (1).png

    I've read many threads, tutorials and pages from unity manual but am sort of out of ideas why the spikes are still there when there shouldn't be any objects that mark the canvas dirty in the first place (none are enabled/disabled or change position/rotation/scale) and even if they were the rebuild should affect a tiny number of UI objects (6-7 max).
     
    Last edited: Apr 24, 2019
  2. jamespaterson

    jamespaterson

    Joined:
    Jun 19, 2018
    Posts:
    399
    seeing it too with 2018.3, simple UI, just a few text boxes
     
  3. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,610
    Please check if the issue also occurs with the latest 2018.4 LTS release, it's 2018.4.5 at the time of writing. If the issue persists and can be reproduced, please submit a bug-report as described in this document:
    https://unity3d.com/unity/qa/bug-reporting

    It's important that you report these issues together with a reproduction project if you want them to get fixed. If you don't do it, it might be a long time until someone else reports them or until Unity Technologies find them.

    After you submitted the bug-report, you receive a confirmation email with a bug-report Case number. Please post the Case number (number only, not the link) in this forum thread for Unity staff to pick up.
     
  4. jamespaterson

    jamespaterson

    Joined:
    Jun 19, 2018
    Posts:
    399
    Looks like at least someone else has the problem on 2019:

    https://forum.unity.com/threads/per...batch-and-uievents-willrendercanvases.704135/

    A quick Google reveals this is a problem which many people have had since at least 2015; there are numerous forum posts and "optimization guides". I doubt unity can fix it; it is probably an underlying limitation of the canvas system and the focus will be on something shiny and new. Personally as i am only using text rendering i will probably try moving to textmeshpro in 3d to avoid canvas altogether perhaps.

    Nevertheless if time allows i will submit a bug report and an example project if i can reduce my 40gb project to something uploadable.
     
  5. jamespaterson

    jamespaterson

    Joined:
    Jun 19, 2018
    Posts:
    399
    Looking at the issue tracker there are 282(!) hits for canvas.buildbatch. i would speculate this is a regression of issue ID

    926629
     
  6. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    There is a bug in 2018 and 2019 causing a stall on this profile marker. We are working on a fix. Thanks for your patience.
     
  7. Gua

    Gua

    Joined:
    Oct 29, 2012
    Posts:
    455
    English is not my first language. Do you mean that in reality Canvas.BuildBatch doesn't consume that much resources and this is a profiler error causing it to provide wrong information? Can we get an issue tracker number for this?

    p.s. I've noticed that it only happens when I add GPU profiler.
    https://i.gyazo.com/bc4d405b3cf0f213a09450b94981f718.png
    https://i.gyazo.com/9566c801adfa2c3922a0d4c49f85e6e6.png
     
    Last edited: Dec 12, 2019