Search Issue Tracker
Won't Fix
Votes
0
Found in
2021.2
2021.2.9f1
2022.1
2022.2
Issue ID
1410334
Regression
No
Editor crashes with no stack trace when loading a new scene in Awake() function
Reproduction steps:
1. Open users attached project
2. Open /_DreamIsland/_Scenes/Title
3. Enter and Exit the Play Mode twice
Expected result: A new scene is loaded
Actual result: Editor crashes
Reproducible with: 2021.2.17f1, 2022.1.0b13, 2022.2.0a8
Could not test with: 2019.4.37f1, 2020.3.31f1 (could not downgrade the project)
Note: sometimes it might take multiple tries for Editor to crash
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
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
Resolution Note:
The crash happens in cri_ware_unity.dll!00007ffe85bc55f0() which seems to be a native plugin made by https://www.criware.com/en/
From my investigation this happens in:
```
private void SceneLoaded(Scene nextScene, LoadSceneMode mode)
{
if (nextScene.name==$"{SceneStateEnum.Title}")
{
bgmManager.PlayAndStopBgm(BgmEnum.TitleBGM, false);
}else if(nextScene.name==$"{SceneStateEnum.Tutorial}")
{
bgmManager.PlayAndStopBgm(BgmEnum.TutorialBGM, true);
}
}
```
because `bgmManager` is null and it calls into native code without any check.
By reading the code I see it adds a `sceneLoaded` callback, but it doesn't remove it.
```
private void Awake()
{
SceneManager.sceneLoaded += SceneLoaded;
}
```
This callback will remain registered and `SceneLoaded` will be called every time a new scene is loaded. Adding
```
private void OnDestroy()
{
SceneManager.sceneLoaded -= SceneLoaded;
}
```
solves the issue, but I think a bug report should be filed to the native plugin maintainers to make sure they handle calls on null pointers