Why does Canvas.BuildBatch happen at random and how can I avoid it during runtime?

Profiler shows that the following is taking around 3 seconds and the game freezes for the whole time:
Canvas.BuildBatch → Canvas.GenerateBatchedMesh → Canvas.FillBatchMesh

It happens once at random time during the first 2-3 minutes of play.

How can I avoid this (any tips?) or how can I force BuildBatch at the beginning of the game?

building the batch happens when something on any of the UI elements changes, so my guess is one of you objects is moving/ changing color/ something else randomly during the game.

It does force a BuildBatch right at the beginning otherwise you’d see no UI.

I don’t seem to change anything, except just one animation which moves the position of the popup, the anchors and everything else staying the same.

Can it happen if a text label is updating every frame?
I also destroy a panel from the canvas at the beginning of the scene, might that be the reason?

P.S.: This hiccup happens only on iOS, it does not happen on Android

I am sure that nothing in the UI changes at the moment of freeze. Tested without destroying the panel, same result. Is there a reason why BuildBatch might take so long?

If anything changes then the batch would need rebuilt. So yes changing the text everyframe if for some reason the verts arnt return the same (although it should) it would cause a dirty on the batch.

It takes so long likely because it is calculating a lot of overlaping elements. we are going to improve this at a later point

1 Like

I removed all the UI elements, but the problem still persists. Been struggling with this problem for weeks now.
I reported it as a bug with more information. If you’d like, you can check Case 649698.

Thanks we’ll take a look once it gets through QA

I’m also having a very similar problem at the moment. Was there any resolution to this issue?

was fixed way back then what are you seeing