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
Comments (1)
-
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
- Crash on SortByExecutionOrder when interrupting the .androidpack import process
- ShaderGraph tab header changes the icon to the VFX Graph icon when ShaderGraph and VFX Graph with the same name are both opened
- The Build Profiles window has usability issues when the panel takes up less than 30% of the screen width
- Inconsistent ShaderGraph RGBA channels compared to the Inspector when "Alpha Is Transparency" is used
- Crash on "The GUID inside 'Assets/asset.png.meta' cannot be extracted by the YAML Parser." when opening the project
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.