I’m encountering some weird issues with serialization of managed data/object references in SubScenes.
In Entities 0.1, I used to be able to serialize references to assets in SharedComponentDatas, but that no longer works in Entities 0.2. I’ve also tried out the new managed components, but those also cause similar issues.
When I run this in Entities 0.2.0 preview.18 with unity version 2019.3.0b12, there’s no information or errors logged during SubScene conversion (not in the editor log either), but after conversion the SubScene won’t load. When it tries to load, it prints a single error about the entity header being missing. The error looks like this:
Loading Entity Scene failed because the entity header file could not be found: 46de8bc0b82483142a499143e1e476fb
I’ve been debugging the internal code as much as I can, but can’t find a cause. I’ve verified that the entity header file in the library cache doesn’t show up after conversion. I can’t seem to find where the asynchronous serialization is done though, as breakpoints in the regular internal WriteEntityScene functions doesn’t work and adding logs in there doesn’t seem to print anything (neither in editor nor in the editor log).
Edit: I’ve now properly reported this in the bug tracker with case number 1201070
Regarding the Attached Sample Project
I’ve been able to reproduce this in a very small scale project that I’m attaching here. In the attached project, open SampleScene and wait for the SubScenes to import. After import, you should see the errors I’m talking about. You should also be able to see that no entities spawn in the Entity Inspector for the two problematic SubScenes.
In the scene, there’s three SubScenes:
- SimpleSubScene - just a sanity check subscene that shows that they actually work and does cause entities to spawn in the editor world.
- SharedComponentReference - using the old style shared component datas to reference a ScriptableObject. Causes the error.
- ManagedComponentReference - using the new managed component datas to reference a ScriptableObject. Causes the error.
The project is made using 2019.3.0b12 and Entities 0.2.0 preview.18
Additional Notes
Also noteworthy is that on a couple rare occasions when I’ve been trying out things related to this, I’ve gotten an omnious warning that sounds like it could be related. It occurs very rarely though, and I can’t seem to find out how to reproduce it:
Error when processing 'AsyncLoadSceneJob(VirtualArtifacts/Extra/05/05943b4ff7b90aac62b03ba4eea1ab85.0.entities)': System.ArgumentException: Requested value outside bounds of UnsafeAppendOnlyBuffer. Remaining bytes: {Buffer->Size - m_Offset} Requested: {structSize}
at Unity.Collections.LowLevel.Unsafe.UnsafeAppendBuffer+Reader.CheckBounds (System.Int32 structSize) [0x00015] in C:\Projects\SerializationIssues\SerializationIssues\Library\PackageCache\com.unity.collections@0.2.0-preview.13\Unity.Collections\UnsafeAppendBuffer.cs:190
at Unity.Collections.LowLevel.Unsafe.UnsafeAppendBuffer+Reader.ReadNext[T] (T& value) [0x00007] in C:\Projects\SerializationIssues\SerializationIssues\Library\PackageCache\com.unity.collections@0.2.0-preview.13\Unity.Collections\UnsafeAppendBuffer.cs:196
at Unity.Entities.Serialization.PropertiesBinaryReader.BeginCollection[TProperty,TContainer,TValue] (TProperty property, TContainer& container, TValue& value, Unity.Properties.ChangeTracker& changeTracker) [0x00032] in C:\Projects\SerializationIssues\SerializationIssues\Library\PackageCache\com.unity.entities@0.2.0-preview.18\Unity.Entities\Serialization\BinaryWriter.cs:450
at Unity.Properties.PropertyVisitor.TryVisitCollectionWithAdapters[TProperty,TContainer,TValue] (TProperty property, TContainer& container, TValue& value, Unity.Properties.ChangeTracker& changeTracker) [0x00057] in C:\Projects\SerializationIssues\SerializationIssues\Library\PackageCache\com.unity.properties@0.10.3-preview\Runtime\Unity.Properties\PropertyVisitor.cs:148
at Unity.Properties.PropertyVisitor.VisitCollectionProperty[TProperty,TContainer,TValue] (TProperty property, TContainer& container, Unity.Properties.ChangeTracker& changeTracker) [0x00021] in C:\Projects\SerializationIssues\SerializationIssues\Library\PackageCache\com.unity.properties@0.10.3-preview\Runtime\Unity.Properties\PropertyVisitor.cs:85
at Unity.Properties.Reflection.ReflectedPropertyBag`1+CollectionPropertyProxy`2[TContainer,TProperty,TValue].Accept[TVisitor] (TContainer& container, TVisitor& visitor, Unity.Properties.ChangeTracker& changeTracker) [0x00000] in C:\Projects\SerializationIssues\SerializationIssues\Library\PackageCache\com.unity.properties@0.10.3-preview\Runtime\Unity.Properties\Reflection\ReflectedPropertyBag.cs:32
at Unity.Properties.Reflection.ReflectedPropertyBag`1[TContainer].Accept[TVisitor] (TContainer& container, TVisitor& visitor, Unity.Properties.ChangeTracker& changeTracker) [0x00006] in C:\Projects\SerializationIssues\SerializationIssues\Library\PackageCache\com.unity.properties@0.10.3-preview\Runtime\Unity.Properties\Reflection\ReflectedPropertyBag.cs:77
at Unity.Properties.PropertyContainer.Visit[TContainer,TVisitor] (TContainer& container, TVisitor& visitor, Unity.Properties.ChangeTracker& changeTracker) [0x00075] in C:\Projects\SerializationIssues\SerializationIssues\Library\PackageCache\com.unity.properties@0.10.3-preview\Runtime\Unity.Properties\PropertyContainerVisit.cs:68
at Unity.Properties.PropertyContainer.Visit[TContainer,TVisitor] (TContainer& container, TVisitor visitor, Unity.Properties.ChangeTracker& changeTracker) [0x00001] in C:\Projects\SerializationIssues\SerializationIssues\Library\PackageCache\com.unity.properties@0.10.3-preview\Runtime\Unity.Properties\PropertyContainerVisit.cs:51
at Unity.Properties.PropertyVisitor.TryVisitContainerWithAdapters[TProperty,TContainer,TValue] (TProperty property, TContainer& container, TValue& value, Unity.Properties.ChangeTracker& changeTracker) [0x0006b] in C:\Projects\SerializationIssues\SerializationIssues\Library\PackageCache\com.unity.properties@0.10.3-preview\Runtime\Unity.Properties\PropertyVisitor.cs:125
at Unity.Properties.PropertyVisitor.VisitProperty[TProperty,TContainer,TValue] (TProperty property, TContainer& container, Unity.Properties.ChangeTracker& changeTracker) [0x00032] in C:\Projects\SerializationIssues\SerializationIssues\Library\PackageCache\com.unity.properties@0.10.3-preview\Runtime\Unity.Properties\PropertyVisitor.cs:55
at Unity.Properties.Reflection.ReflectedPropertyBag`1+PropertyProxy`2[TContainer,TProperty,TValue].Accept[TVisitor] (TContainer& container, TVisitor& visitor, Unity.Properties.ChangeTracker& changeTracker) [0x00000] in C:\Projects\SerializationIssues\SerializationIssues\Library\PackageCache\com.unity.properties@0.10.3-preview\Runtime\Unity.Properties\Reflection\ReflectedPropertyBag.cs:20
at Unity.Properties.Reflection.ReflectedPropertyBag`1[TContainer].Accept[TVisitor] (TContainer& container, TVisitor& visitor, Unity.Properties.ChangeTracker& changeTracker) [0x00006] in C:\Projects\SerializationIssues\SerializationIssues\Library\PackageCache\com.unity.properties@0.10.3-preview\Runtime\Unity.Properties\Reflection\ReflectedPropertyBag.cs:77
at Unity.Properties.PropertyContainer.Visit[TContainer,TVisitor] (TContainer& container, TVisitor& visitor, Unity.Properties.ChangeTracker& changeTracker) [0x00075] in C:\Projects\SerializationIssues\SerializationIssues\Library\PackageCache\com.unity.properties@0.10.3-preview\Runtime\Unity.Properties\PropertyContainerVisit.cs:68
at Unity.Properties.PropertyContainer.Visit[TContainer,TVisitor] (TContainer& container, TVisitor visitor, Unity.Properties.IVersionStorage versionStorage) [0x00009] in C:\Projects\SerializationIssues\SerializationIssues\Library\PackageCache\com.unity.properties@0.10.3-preview\Runtime\Unity.Properties\PropertyContainerVisit.cs:22
at Unity.Entities.Serialization.BoxedProperties+ReadBoxedClassForwarder.Invoke[T] () [0x00016] in C:\Projects\SerializationIssues\SerializationIssues\Library\PackageCache\com.unity.entities@0.2.0-preview.18\Unity.Entities\Serialization\BinaryWriter.cs:38
at Unity.Properties.PropertyBag`1[TContainer].Cast[TCallback] (TCallback& callback) [0x00001] in C:\Projects\SerializationIssues\SerializationIssues\Library\PackageCache\com.unity.properties@0.10.3-preview\Runtime\Unity.Properties\IPropertyBag.cs:38
at Unity.Entities.Serialization.BoxedProperties.ReadBoxedClass (System.Type type, Unity.Entities.Serialization.PropertiesBinaryReader reader) [0x0001c] in C:\Projects\SerializationIssues\SerializationIssues\Library\PackageCache\com.unity.entities@0.2.0-preview.18\Unity.Entities\Serialization\BinaryWriter.cs:58
at Unity.Entities.Serialization.SerializeUtility.ReadSharedComponents (Unity.Entities.ExclusiveEntityTransaction manager, Unity.Entities.Serialization.PropertiesBinaryReader managedDataReader, Unity.Collections.NativeArray`1[T] sharedComponentRecordArray) [0x00022] in C:\Projects\SerializationIssues\SerializationIssues\Library\PackageCache\com.unity.entities@0.2.0-preview.18\Unity.Entities\Serialization\SerializeUtility.cs:600
at Unity.Entities.Serialization.SerializeUtility.DeserializeWorld (Unity.Entities.ExclusiveEntityTransaction manager, Unity.Entities.Serialization.BinaryReader reader, System.Object[] unityObjects) [0x00119] in C:\Projects\SerializationIssues\SerializationIssues\Library\PackageCache\com.unity.entities@0.2.0-preview.18\Unity.Entities\Serialization\SerializeUtility.cs:82
at Unity.Scenes.AsyncLoadSceneOperation+AsyncLoadSceneJob.Execute () [0x00057] in C:\Projects\SerializationIssues\SerializationIssues\Library\PackageCache\com.unity.entities@0.2.0-preview.18\Unity.Scenes.Hybrid\AsyncLoadSceneOperation.cs:99
UnityEngine.Debug:LogWarning(Object)
Unity.Debug:LogWarning(String) (at Library/PackageCache/com.unity.entities@0.2.0-preview.18/Unity.Entities/Stubs/Unity/Debug.cs:15)
Unity.Scenes.SceneSectionStreamingSystem:UpdateLoadOperation(AsyncLoadSceneOperation, World, Entity) (at Library/PackageCache/com.unity.entities@0.2.0-preview.18/Unity.Scenes.Hybrid/SceneSectionStreamingSystem.cs:370)
Unity.Scenes.SceneSectionStreamingSystem:ProcessActiveStreams() (at Library/PackageCache/com.unity.entities@0.2.0-preview.18/Unity.Scenes.Hybrid/SceneSectionStreamingSystem.cs:273)
Unity.Scenes.SceneSectionStreamingSystem:OnUpdate() (at Library/PackageCache/com.unity.entities@0.2.0-preview.18/Unity.Scenes.Hybrid/SceneSectionStreamingSystem.cs:474)
Unity.Entities.ComponentSystem:InternalUpdate() (at Library/PackageCache/com.unity.entities@0.2.0-preview.18/Unity.Entities/ComponentSystem.cs:843)
Unity.Entities.ComponentSystemBase:Update() (at Library/PackageCache/com.unity.entities@0.2.0-preview.18/Unity.Entities/ComponentSystem.cs:307)
Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.2.0-preview.18/Unity.Entities/ComponentSystemGroup.cs:101)
Unity.Entities.ComponentSystem:InternalUpdate() (at Library/PackageCache/com.unity.entities@0.2.0-preview.18/Unity.Entities/ComponentSystem.cs:843)
Unity.Entities.ComponentSystemBase:Update() (at Library/PackageCache/com.unity.entities@0.2.0-preview.18/Unity.Entities/ComponentSystem.cs:307)
Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at Library/PackageCache/com.unity.entities@0.2.0-preview.18/Unity.Entities/ScriptBehaviourUpdateOrder.cs:152)
I hope this will help you in finding the issue!
5208428–518315–SerializationIssues.zip (34.8 KB)