#[BUG] Swapping scene with subscene in EnteredEditMode cause exceptions

1 messages · Page 1 of 1 (latest)

potent tiger
#

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) 😄

dusk turtle
#

No worries, I'll play the game of tag internally 😆

tranquil smelt
#

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.

potent tiger
#

I'll give you repo project right here (pretty simple and minimal couple of megabytes)

#

Gimme a minute

potent tiger
potent tiger
#

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.

  1. 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",
  1. Open project
  2. Open scene SceneToOpenInEditor
  3. Hit Play
  4. Wait objects appears in Game view for a couple of seconds
  5. Hit Stop Playmode
  6. 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)
#

All these errors triggered by switching Scene (from Scene with SubScenes to another Scene) in PlayModeStateChange.EnteredEditMode

tranquil smelt
potent tiger
#

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

tranquil smelt
#

We got it! Had to turn off burst safety checks.

potent tiger
#

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!

potent tiger
#

@tranquil smelt is there anything I can provide? Or that’s enough?

tranquil smelt
#

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).

potent tiger
tranquil smelt
#

Yep, should be!

potent tiger
#

👀