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
- 2D Freeform Light shadows disappear when light center is offset from shape bounds
- Crash on MarkAllDependencies when opening scenes with Assets from the YarnSpinner package
- Crash on CollectAllSceneManagerAndObjectIDs when opening a specific Scene
- GPU device suspended error when replaying a video in the Video Player with NVIDIA Vertical Sync set to Fast
- GPU device suspended error when replaying a video in the Video Player with NVIDIA Vertical Sync set to Fast
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