(IN-60915) [1.2.0-exp.3] Failed to bake environment subscene properly

IN-60915

It just failed to bake environment subscene and log a usual log and error.

[spoiler]

[Worker0] Exception thrown during SubScene import: System.IndexOutOfRangeException: Index 2325 is out of range of '8' Length.
at Unity.Collections.NativeArray1[T].FailOutOfRangeError (System.Int32 index) [0x00085] in <30adf90198bc4c4b83910c6fb1877998>:0
at Unity.Entities.EntityRemapUtility.AddEntityRemapping (Unity.Collections.NativeArray
1[Unity.Entities.EntityRemapUtility+EntityRemapInfo]& remapping, Unity.Entities.Entity source, Unity.Entities.Entity target) [0x00000] in .\Library\PackageCache\com.unity.entities@1.2.0-exp.3\Unity.Entities\EntityRemapUtility.cs:56
at Unity.Scenes.Editor.EditorEntityScenes.WriteEntitySceneInternal (Unity.Entities.EntityManager entityManager, Unity.Entities.Hash128 sceneGUID, System.String sceneName, UnityEditor.AssetImporters.AssetImportContext importContext, System.Collections.Generic.List1[T] sectionRefObjs, Unity.Scenes.Editor.WriteEntitySceneSettings writeEntitySceneSettings) [0x002ad] in .\Library\PackageCache\com.unity.entities@1.2.0-exp.3\Unity.Scenes.Editor\EditorEntityScenes.cs:429
at Unity.Scenes.Editor.EditorEntityScenes.WriteEntitySceneInternalBaking (Unity.Entities.EntityManager entityManager, Unity.Entities.Hash128 sceneGUID, System.String sceneName, UnityEditor.AssetImporters.AssetImportContext importContext, System.Collections.Generic.List
1[T] sectionRefObjs, Unity.Scenes.Editor.WriteEntitySceneSettings writeEntitySceneSettings) [0x0011d] in .\Library\PackageCache\com.unity.entities@1.2.0-exp.3\Unity.Scenes.Editor\EditorEntityScenes.cs:144
at Unity.Scenes.Editor.EditorEntityScenes.BakeAndWriteEntityScene (UnityEngine.SceneManagement.Scene scene, Unity.Entities.BakingSettings settings, System.Collections.Generic.List`1[T] sectionRefObjs, Unity.Scenes.Editor.WriteEntitySceneSettings writeEntitySettings) [0x00083] in .\Library\PackageCache\com.unity.entities@1.2.0-exp.3\Unity.Scenes.Editor\EditorEntityScenes.cs:84
at Unity.Scenes.Editor.SubSceneImporter.ImportBaking (UnityEditor.AssetImporters.AssetImportContext ctx, UnityEngine.SceneManagement.Scene scene, Unity.Scenes.SceneWithBuildConfigurationGUIDs sceneWithBuildConfiguration, Unity.Entities.Build.IEntitiesPlayerSettings settingsAsset, UnityEngine.GameObject prefab) [0x00070] in .\Library\PackageCache\com.unity.entities@1.2.0-exp.3\Unity.Scenes.Editor\SubSceneImporter.cs:123
at Unity.Scenes.Editor.SubSceneImporter.OnImportAsset (UnityEditor.AssetImporters.AssetImportContext ctx) [0x000ba] in .\Library\PackageCache\com.unity.entities@1.2.0-exp.3\Unity.Scenes.Editor\SubSceneImporter.cs:202

[/spoiler]

[spoiler]

Loading Entity Scene failed because the entity header file couldn't be resolved. This might be caused by a failed import of a subscene. Please try to reimport the subscene Environment from its inspector, look at any errors/exceptions in the console or look at the asset import worker log in E:\UnityBug\EntitiesGraphicsBug\Logs. scenePath=Assets/Scene/SubScene/Environment.unity guid=b4cff685a7c526e4cba853c475d9843e
UnityEngine.Debug:LogError (object)
Unity.Debug:LogError (object) (at ./Library/PackageCache/com.unity.entities@1.2.0-exp.3/Unity.Entities/Stubs/Unity/Debug.cs:11)
Unity.Scenes.SceneHeaderUtility:LogHeaderLoadError (Unity.Scenes.SceneHeaderUtility/HeaderLoadStatus,Unity.Entities.Hash128) (at ./Library/PackageCache/com.unity.entities@1.2.0-exp.3/Unity.Scenes/SceneHeaderUtility.cs:339)
Unity.Scenes.SceneHeaderUtility:FinishHeaderLoad (Unity.Scenes.RequestSceneHeader,Unity.Entities.Hash128,string) (at ./Library/PackageCache/com.unity.entities@1.2.0-exp.3/Unity.Scenes/SceneHeaderUtility.cs:142)
Unity.Scenes.ResolveSceneReferenceSystem/ResolveSceneReferenceSystem_2E14F795_LambdaJob_0_Job:OriginalLambdaBody (Unity.Entities.Entity,Unity.Scenes.RequestSceneHeader&,Unity.Entities.SceneReference&,Unity.Scenes.ResolvedSceneHash&,Unity.Entities.RequestSceneLoaded&) (at ./Library/PackageCache/com.unity.entities@1.2.0-exp.3/Unity.Scenes/ResolveSceneReferenceSystem.cs:228)
Unity.Scenes.ResolveSceneReferenceSystem/ResolveSceneReferenceSystem_2E14F795_LambdaJob_0_Job:RunWithStructuralChange (Unity.Entities.EntityQuery) (at ./SystemGenerator/Unity.Entities.SourceGen.SystemGenerator.SystemGenerator/Temp/GeneratedCode/Unity.Scenes/ResolveSceneReferenceSystem_System_14342649320.g.cs:262)
Unity.Scenes.ResolveSceneReferenceSystem:ResolveSceneReferenceSystem_2E14F795_LambdaJob_0_Execute (bool&) (at ./SystemGenerator/Unity.Entities.SourceGen.SystemGenerator.SystemGenerator/Temp/GeneratedCode/Unity.Scenes/ResolveSceneReferenceSystem
_System_14342649320.g.cs:294)
Unity.Scenes.ResolveSceneReferenceSystem:OnUpdate () (at ./Library/PackageCache/com.unity.entities@1.2.0-exp.3/Unity.Scenes/ResolveSceneReferenceSystem.cs:215)
Unity.Entities.SystemBase:Update () (at ./Library/PackageCache/com.unity.entities@1.2.0-exp.3/Unity.Entities/SystemBase.cs:418)
Unity.Entities.ComponentSystemGroup:UpdateAllSystems () (at ./Library/PackageCache/com.unity.entities@1.2.0-exp.3/Unity.Entities/ComponentSystemGroup.cs:723)
Unity.Entities.ComponentSystemGroup:OnUpdate () (at ./Library/PackageCache/com.unity.entities@1.2.0-exp.3/Unity.Entities/ComponentSystemGroup.cs:681)
Unity.Entities.SystemBase:Update () (at ./Library/PackageCache/com.unity.entities@1.2.0-exp.3/Unity.Entities/SystemBase.cs:418)
Unity.Entities.ComponentSystemGroup:UpdateAllSystems () (at ./Library/PackageCache/com.unity.entities@1.2.0-exp.3/Unity.Entities/ComponentSystemGroup.cs:723)
Unity.Entities.ComponentSystemGroup:OnUpdate () (at ./Library/PackageCache/com.unity.entities@1.2.0-exp.3/Unity.Entities/ComponentSystemGroup.cs:681)
Unity.Entities.InitializationSystemGroup:OnUpdate () (at ./Library/PackageCache/com.unity.entities@1.2.0-exp.3/Unity.Entities/DefaultWorld.cs:169)
Unity.Entities.SystemBase:Update () (at ./Library/PackageCache/com.unity.entities@1.2.0-exp.3/Unity.Entities/SystemBase.cs:418)
Unity.Entities.ScriptBehaviourUpdateOrder/DummyDelegateWrapper:TriggerUpdate () (at ./Library/PackageCache/com.unity.entities@1.2.0-exp.3/Unity.Entities/ScriptBehaviourUpdateOrder.cs:523)

[/spoiler]

Thanks for the call stacks and the project (in your bug report). I managed to repro the issue, and it's a bug in our package and I'm the one who wrote the incorrect code.

I'll make sure a fix for this goes into the next release. Meanwhile, what you can do to get unblocked is either:
- Don't upgrade to 1.2 just yet
- Define ENTITY_STORE_V1 in your project, this will opt out of the global entity store. This is not a long term solution, the old entity store will go away but we're keeping it around for a bit as a backup solution for problems like this one.
- One last option which clearly won't work for you but might help others : the error is related to the use of sections in the SubScene. So removing the sections will fix the error but I'm not suggesting this in your case because from what I saw, you're using them a lot.

One additional bit of info is that the second error "Loading Entity Scene failed because the entity header file couldn't be resolved." basically means "something went wrong during baking". So when this happens, the right thing to do is to look for the error in baking, which is exactly what you did. So I'm only adding this note here as a reference for other people.

Thanks again for your help, and sorry for the inconvenience.

1 Like

I suggested he try use v1 a couple of days ago and unfortunately he reported it had a compile error (second hand report, have not tried this myself)

[quote]
Library\PackageCache\com.unity.entities@1.2.0-exp.3\Unity.Entities.Editor\Hierarchy\Model\HierarchyNameStore.cs(117,18): error CS0246: The type or namespace name 'EntityNameStoreAccess' could not be found (are you missing a using directive or an assembly reference?)
`Library\PackageCache\com.unity.entities@1.2.0-exp.3\Unity.Entities.Editor\Hierarchy\Model\HierarchySearch.cs(397,31): error CS0246: The type or namespace name 'EntityNameStoreAccess' could not be found (are you missing a using directive or an assembly reference?)
[/quote]

-EDIT-

Tried to repo this myself, can't seem to? ENTITY_STORE_V1 seems to compile fine so maybe just ignore this :sweat_smile:

I just checked the code at those locations and the defines are setup properly, so this should work. :face_with_spiral_eyes:


Hi. At latest 1.2.0-pre.4, the error is fixed but now scene section streaming is completely broken that either it load the entire subscene or entire subscene is not loaded anymore. Basically it it's no longer able to stream in and out scene sections anymore.