Search Issue Tracker
Won't Fix
Votes
0
Found in
2020.3.42f1
2021.3.14f1
2022.1.23f1
2022.2.0b16
2023.1.0a19
2023.2.0a1
Issue ID
UUM-19490
Regression
No
Silent crash when Canvas.ForceUpdateCanvases function is called
Reproduction steps:
# Open the attached project “CrashReproduction”
# Open the “Assets/Crasher” prefab
Expected result: Unity opens the prefab
Actual result: Unity crashes
Reproducible with: 2020.3.42f1, 2021.3.14f1, 2022.1.23f1, 2022.2.0b16, 2023.1.0a19
Reproducible on: macOS 13.0
Not reproducible on: Windows 10
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
- "ArgumentException" errors thrown when enabling “Screenshot Camera 6” GameObject in High Definition 3D Sample Template
- Inaccurate collision detection in OnTriggerStay when alternating isKinematic and Collision Detection modes in FixedUpdate
- [TMP] Usability - Font Styles button icons should display text effect
- Shader warning in 'Hidden/Universal Render Pipeline/LensFlareDataDriven' is thrown after building Universal 3D Template Project
- [URP] "ShaderData" namespace error is thrown when building a project with "URP RenderGraph Samples"
Resolution Note:
The ForceUpdateCanvases function causes the Slider component to trigger the OnValueChangedEvent (editor only). In the example attached, ForceUpdateCanvases is called when OnValueChanged is called, so we enter an infinite recursion. This behaviour exists since 2014, and affects other components. While it is debatable whether this beheviour should exist, changing it would likely cause unwanted side effects and bugs.
Instead, we suggest to avoid triggering the infinite loop by unregistering and registering to the event:
// Prevent infinite loop in the editor
#if UNITY_EDITOR
slider.onValueChanged.RemoveListener(Crash);
Canvas.ForceUpdateCanvases();
slider.onValueChanged.AddListener(Crash);
#else
Canvas.ForceUpdateCanvases();
#endif