Search Issue Tracker
Won't Fix
Won't Fix in 2023.2.X
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
- Out-of-bounds memory access with multiple CanvasRenderers under a Canvas when using Mesh API
- Inspector tries to access file after it was deleted when the file was locked in Inspector window
- Changing Transform values in Search window Inspector loses focus while dragging and stopping mouse without releasing dragging action
- Saving changes on the dirty VFX Graph during the Play mode throws "The referenced script (Unknown) on this Behaviour is missing!" warnings
- VFX Graph Debug Info overlaps the "Initialize" block debug info by default
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
Resolution Note (2023.2.X):
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