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
- NullReferenceException when setting 'isTextObjectScaleStatic' to false on a disabled TextMeshPro GameObject
- Shader Stripping Custom Options disappear when exiting Play mode without reloading Domain
- Decals do not get projected when 'Rendering Layer Mask' on a GameObject is 23rd Layer or above due to encoding/decoding issues
- Deriving from SearchContextAttribute doesn't always work
- Scripting API documentation is missing for macOS editor extensions
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