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

uGUI

-

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

  1. 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.

Comments (1)

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.