Swapping scene with subscens in EditorApplication.playModeStateChanged -> EnteredEditMode cause SceneSectionStreamingSystem throw. Use case - we have some mechanism which is working fine (and worked before subscenes in old projects), that allow us to load specific scene on entering Playmode (for example we swap to scene with subscenes in ExitingEditMode to load that scene before playmode, that part works just fine! And then on exit Playmode (EnteredEditMode) you'll see error above when you try to EditorSceneManager.OpenScene(previousActiveScene, OpenSceneMode.Single); another scene, because before Playmode we've changed to scene with subscenes and it becomes active editor scene (to which editor automatically will swap after Playmode) but after Playmode SceneSectionStreaming trying to do it's stuff on subscenes in scene and we load another scene at the same time (which forces scene with subscenes to unload). Expected behavior is SceneSectionStreamingSystem shouldn't fail if we unload scene with subscenes in EnteredEditMode @dusk turtle will ping you mate (sorry) 😄
#[BUG] Swapping scene with subscene in EnteredEditMode cause exceptions
1 messages · Page 1 of 1 (latest)
No worries, I'll play the game of tag internally 😆
If I understand correctly, you have custom code that loads a subscene on entering playmode. This works fine (and totally works with scenes), but when you exit playmode (and enter edit mode), it generates the error above?
Any repo steps or (even better) a logged bug with a repro project would be super helpful.
A bit different. I have code that loads Scene which contains subscene
I'll give you repo project right here (pretty simple and minimal couple of megabytes)
Gimme a minute
Thank you 😄
Ok
Narrowed it down even more
these 2 errors are separate but reproduces here
Let me show
@tranquil smelt
Error (ArgumentException: We are reading a UnityEngine.Object but the deserialized index is out of range for the given object table.) and warnings happening when there is entities spawned at runtime from entity in subscene, one error and one warning per SubScene.
Error (IndexOutOfRangeException: Index 0 is out of range of '0' Length.) happens when there is UnityObjectRef in component baked in SubScene.
- Unity 6000.3.0a2, Debug Mode (Mode probably unrelated, just in case)
"com.unity.entities": "1.4.0-pre.3",
"com.unity.entities.graphics": "1.4.13-pre.3",
- Open project
- Open scene
SceneToOpenInEditor - Hit Play
- Wait objects appears in Game view for a couple of seconds
- Hit Stop Playmode
- Look at console with a sad long sigh (Could throw on second run, could throw right on first, as it's depends on async SubScene loading)
Repro project
All these errors triggered by switching Scene (from Scene with SubScenes to another Scene) in PlayModeStateChange.EnteredEditMode
Hmm, we can't seem to repro it here with the attached project. Video attached.
Well fresh project, just made it and immediately reproduced. Are you in Debug Mode? Burst enabled? And as I mentioned it could happen not on first Play, are you on 6000.3.0a2?
As it all related to async subscenes operations
Just opened to test again on another machine

Yep tested with Release mode - doesn't happen, switched back to Debug mode - happens
We got it! Had to turn off burst safety checks.
Interesting ))
Yeah I have burst off
Tested with Burst On - throws too ))
I think all these assumptions (burst, debug mode etc.) irrelevant and it all just async nature and with/without some things it just happens to load faster and not throw then 😄
Yeah sometimes throw sometimes no (with/without burst different combinations)
Favorite type of bugs - fickle!
@tranquil smelt is there anything I can provide? Or that’s enough?
Hey @potent tiger, apologies for the late response. I haven't had a chance to look at the bug other than to repro and create a ticket (with your repro).
No problem, no rush here just asked if there is enough info from me for ticket
Yep, should be!
👀