Performance spikes on Canvas.BuildBatch and UIEvents.WillRenderCanvases

Hello, we’re having performance problems with UIEvents.WillRenderCanvases and Canvas.BuildBatch.

It only happens in build version and when the camera is moving. There aren’t spikes if the camera is static.

We are having this problem since we updated the project to 2019.1.8, in the last version we used (2017.3.1p1) the game was running fine.

I’m trying to find out what is causing it but I can’t find a solution. With this issue the game is not playable and we can’t update the public build until we fix it.

Does anyone have any clue of what could be happening?

Thanks!

1 Like

Does this look like a regression of issue ID

926629

?

I’m having this issue in 2018.4.7.f1.
According to the issue tracker, hasn’t been fixed for anything beyond 2018.1

I used to have a similar problem. I read about the building of the canvas and i found out that on every movement the canvas renders everything. "The problem is that, when one or more elements change on a Canvas, the whole Canvas has to be re-analyzed to figure out how to optimally draw its elements." (That includes the positioning by the camera)
I’d recommend you read here about some UI optimization tips.
I hope this helps.

1 Like

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.

1 Like

Can you provide additional information on the bug, such as an issuetracker link? I’m also seeing this issue and would like to understand if I need to wait for this fix or if there is some kind of work-around/change I can make to alleviate the stall.

Sure, here it is: https://issuetracker.unity3d.com/issues/semaphore-dot-waitforsignal-causes-a-slow-editor-when-entering-play-mode

The info on that page doesn’t mention that it occurs in 2018.4 and 2019.1 too, but it does.

I don’t know of any workarounds for it at this time, unfortunately.

EDIT: There is this one too: https://issuetracker.unity3d.com/issues/canvas-dot-buildbatch-50-percent-70-percent-cpu-spikes-when-dragging-mouse-from-unity-window-to-any-other-os-window

With apologies for necro’ing, is this issue editor-only or does it also cause performance slowdowns in the release version?

I would expect it to affect players too

Any idea what version # has a fix for this? It’s a pretty major issue that i’m surprised more people aren’t noticing.