Why are Canvas.BuildBatch() spikes still occuring ?

I’m developing a 3D car game and am encountering Canvas.BuildBatch() huge spikes as seen here :

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

4463983--409954--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

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).

seeing it too with 2018.3, simple UI, just a few text boxes

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:

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.

Looks like at least someone else has the problem on 2019:

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.

Looking at the issue tracker there are 282(!) hits for canvas.buildbatch. i would speculate this is a regression of issue ID

926629

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.

4 Likes

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