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
- "Property (urp_ReflProbes_BoxMin) exceeds previous array size" warning spams console after switching platforms
- Have to change Input Mapping Path twice for change to take effect when Auto-Save is enabled
- No Duplicate option is available when right clicking States in the Animator Window even though it's available via Shortcut
- Copied and Pasted States appear in a set location instead of where the Users cursor is located at when using the Pasting Shortcut
- Animator Component information box text is not centered
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.