Search Issue Tracker
Fix In Review for 2022.2.X
Votes
0
Found in
2019.4
2020.3
2021.3
2022.1
2022.2
2022.2.0a10
Issue ID
1420752
Regression
No
Getting "RectTransform.rect" is expensive
How to reproduce:
1. Open the user attached project (RectTransformPerfIssue.zip)
2. Make sure "Sample1" scene is open
3. Press Ctrl+7 to open the Profiler window
4. Enter Play Mode
5. Wait for a few seconds and select any part of the "CPU Usage" graph
6. In the "Raw Hierarchy" section under the graphs expand: PlayerLoop > PreLateUpdate.ScriptRunBehaviourLateUpdate
7. Observe the "Time" value for the "LateBehaviourUpdate" entry
Expected result: the time is less than 1 ms
Actual result: the time is about 2 ms
Reproducible with: 2019.4.39f1, 2020.3.34f1, 2021.3.3f1, 2022.1.1f1, 2022.2.0a14
Reproducible on: Windows 10, Ubuntu 20.04
Notes:
1. Additional details about the issue are available in the user attached video
2. The issue is not reproducible with the time being less when calling "RectTransform.rect" 1000 times compared to calling "RectTransform.localToWorldMatrix" 1000 times, and using "System.Diagnostics.Stopwatch" to benchmark the time they took to run
-
Peter77
May 18, 2022 13:27
Related forum thread:
https://forum.unity.com/threads/case-1420752-recttransform-rect-very-expensive.1268918/
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- "EndLayoutGroup: BeginLayoutGroup must be called first" error is thrown when changing Shader Precision Model from the Build Profiles window
- White artifacts/outlines are visible in the Garden Scene when viewing at meshes from a distance
- Shader warnings "Sprite-Unlit-Default" are thrown after building 2D Platrformer Microgame Template
- [Android] HLSL shader becomes corrupted when running on an Android device
- Missing spaces in "Welcome to VR Mutiplayer Template Project" Welcome Dialog window
Resolution Note (fix version 2022.2):
RectTransform.rect has to check and validate that the TransformChange dispatch system has not dirtied any parent object which would require updating of the rect. This check is not free but is necessary to ensure we dont return a old value.