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
- [Android][iOS][UnityPlayerActivity] Legacy InputField.onEndEdit is not called when ending text edit
- Transform corruption and/or crash on PhysX::CreateCharacterController when spawning physics objects into Prefab stages
- UNITY_EDITOR data is Serialized into AssetBundle when building on the active Build Target
- "TLS Allocator ALLOC_TEMP_TLS, underlying allocator ALLOC_TEMP_MAIN has unfreed allocations..." error when changing the Packages "Cache Location" folder
- CompilationPipeline.assemblyCompilationFinished() hangs unity when reloading domain
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