Hi all,
I didn’t see this on the 5.4b23 Known Issues list so thought I’d post my submitted bug here to save others the trouble.
Bug # 810190: Every GameObject under a Canvas adds 4 calls to “CanvasRenderer.OnTransformChanged”.
1. What happened
Regression.
With Unity 5.4b23, every GameObject under a Canvas adds 4 calls to “CanvasRenderer.OnTransformChanged”, even if the child GameObjects are disabled.
This has severe performance issues in my production project, as my Canvases contain thousands of child elements (though not all active at once).
This bug was not present in 5.4b21.
I have not used 5.4b22 so can’t comment on that.
(The repo project is just a scene with a Canvas and 2,000 GameObjects with the UI.Text components added.)
2. How we can reproduce it using the example you attached
Open DefaultScene.unity and click Play.
Open the Profiler. Note there are 8,000 calls to “CanvasRenderer.OnTransformChanged” per frame, resulting in a large amount of “Total %”. (there are 2,000 Text objects under the Canvas, so it’s 4 calls per object)
Note too that the 2,000 child GameObjects are disabled, so their Transforms should not be changing nor triggering these calls.
In my production product, I had over 24,000 calls per frame in one of my scenes when most of my UI elements were loaded into the scene. The calls were adding lots of GC, as well as killing the framerate.
Hope this gets fixed
I’ll go back to 5.4b21 for now.