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
- Popup windows spawn on the incorrect monitor when the Editor is placed near the boundary of scaled monitor next to a monitor with different scaling
- Hidden Tabs do not shift into empty space after closing visible Tabs
- [Android] Application not deployed on a device when "activity-alias" is used in the AndroidManifest
- Shader compile process adds shader ID to the constant buffer name when the word "Globals" is being used in Vulkan
- Audio Mixer Snapshot link to the documentation isn’t working
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