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
- WebGL Player with WebGPU Graphics API fails to render Scene when custom Render Feature is used
- “EndLayoutGroup” error thrown when changing Shader Precision Model settings in Build Profiles window > Player Settings Overrides
- Button hover state uses default theme color when a custom .uss is applied
- Samples Showcase script warning does not clear after enabling required settings until GameObject is reselected
- VFX Particles receive shadow artifacts when using ShaderGraph with enabled shadows and Face Camera Plane Orient mode
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