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
- [Mobile] Developer Console does not appear when an error is thrown
- [HDRP] Game view renders artifacts when Camera's Component "Post Anti-aliasing" is set to "TAA" and Dynamic Resolution's "Forced Screen Percentage" is changed
- A deactivated Prefab's name color becomes white when a GameObject in the scene is deactivated
- The Game view becomes blank when using Frame Debugger with MSAA and Texture binding enabled in Play Mode
- NullReferenceException is thrown when changing the Inspector preview selection
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.