Open solonrice opened 1 year ago
Thank you! I looked at the whole thing earlier. Quasi just dragged it into Arch.Extended.Sample. Because I updated Arch.Persistence in the meantime because of the new arch release, I had to use new compressed strings.
Anyway, I could run it without problems and there were no errors :/ Where did you include the whole thing? Is there some more information?
You know, it just occurred to me that I had the Arch.Extended
repo checked out and added directly to my solution. I’ll try again with nuget package and see if different result.
You know, it just occurred to me that I had the
Arch.Extended
repo checked out and added directly to my solution. I’ll try again with nuget package and see if different result.
I had it also checked out and well... it worked for me :o Since another user has a similar issue... i actually believe its some sort of cpu/os/environment thing. What os are ya using? And what engine? Could you probably debug the iusse yourself to see why it fucks up and why its happening?
I'm also getting this error
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Arch.Core.Chunk.GetArray(Arch.Core.Utils.ComponentType)
at Arch.Persistence.ChunkFormatter.Deserialize(MessagePack.MessagePackReader ByRef, MessagePack.MessagePackSerializerOptions)
at Arch.Persistence.ArchetypeFormatter.Deserialize(MessagePack.MessagePackReader ByRef, MessagePack.MessagePackSerializerOptions)
at Arch.Persistence.WorldFormatter.Deserialize(MessagePack.MessagePackReader ByRef, MessagePack.MessagePackSerializerOptions)
at MessagePack.MessagePackSerializer.Deserialize[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](MessagePack.MessagePackReader ByRef, MessagePack.MessagePackSerializerOptions)
at MessagePack.MessagePackSerializer.Deserialize[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]](System.ReadOnlyMemory`1<Byte>, MessagePack.MessagePackSerializerOptions, System.Threading.CancellationToken)
at Arch.Persistence.ArchBinarySerializer.Deserialize(Byte[])
at Game.MainMenu.OnAwake()
at FlaxEngine.Interop.NativeInterop+Invoker+InvokerNoRet0`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].InvokeThunk(System.Object, FlaxEngine.Interop.ManagedHandle, IntPtr*)
at FlaxEngine.Interop.NativeInterop+ThunkContext.InvokeThunk(FlaxEngine.Interop.ManagedHandle, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr, IntPtr)
Segmentation fault
It only happens in FlaxEngine builds, not in editor. And this is the code that I use to cause it:
var world = World.Create();
world.Create(new TestStruct3());
var serializer = new ArchBinarySerializer();
var bytes = serializer.Serialize(world);
world = serializer.Deserialize(bytes);
edit: where TestStruct3 just holds an int
I think problem comes from this lookup array and the componentType ID. I am gonna go deeper to see why the lookup array is wrong or if the ID itself is wrong, but maybe you got a clue from this
Thanks for investigating! Excited what you might else discover ^^ Could it be related to your other issue https://github.com/genaray/Arch.Extended/issues/40#issuecomment-1783227980 ?
For some reason, when you convert sourceArray.GetType().GetElementType() to (ComponentType), eventually it tries to do ComponentRegistry.TypeToComponentType.TryGetValue, the correct type is inside the dict as key, but it somehow fails the TryGet and thus it Adds it to the component registry once more, generating a duplicated entry
For some reason, when you convert sourceArray.GetType().GetElementType() to (ComponentType), eventually it tries to do ComponentRegistry.TypeToComponentType.TryGetValue, the correct type is inside the dict as key, but it somehow fails the TryGet and thus it Adds it to the component registry once more, generating a duplicated entry
Well that explains the issue. However i dont get why it should do this... This would mean that the type is "different" somehow.
Is this still the case in the more recent versions of arch and arch extended?
I'm using recent versions of Arch and Extended serialization, I've tested only binary so far but I didn't run into this anymore.
Thank you for implementing the serialization! I recently had a chance to try it out and found an issue when using multiple worlds. The TLDR is basically this:
If you create two worlds and add an entity to each (with a component), serialize both worlds, then deserialize them later in a different order and in a different process, an
AccessViolationException
is thrown in the MessagePack formatters.It looks like the exception is thrown almost every time in the
ChunkFormatter
implementation when the chunk array is setup for the first component type.Here is some code to help reproduce it:
You can simply run the
TestDeserialized()
method, which has the encoded world already there. But of course, prove it out completely by runningTestSerialized()
, copying the output of each world (A and B) to theTestDeserialized()
method, then running that method to show theAccessViolationException
.Thanks again for an awesome ECS!
EDIT: This also happens with the
ArchJsonSerializer
, for what it's worth.