Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Components not being created due to deserialization error #7317

Open
trundlr opened this issue Jan 5, 2025 · 1 comment
Open

Components not being created due to deserialization error #7317

trundlr opened this issue Jan 5, 2025 · 1 comment
Assignees

Comments

@trundlr
Copy link

trundlr commented Jan 5, 2025

Describe the bug

When playing Grubs on live, clients (non-host) get the following error:

2025/01/05 01:17:28.6333    [GameMenu] Error when deserializing GrubsTerrain on (Terrain).SdfWorld ([A]Sandbox.Sdf.Sdf2DWorld cannot be cast to [B]Sandbox.Sdf.Sdf2DWorld. Type A originates from 'package.library.facepunch.libsdf, Version=0.0.116.0, Culture=neutral, PublicKeyToken=null' in the context '"IsolatedAssemblyContext" Sandbox.Internal.IsolatedAssemblyContext #13' in a byte array. Type B originates from 'package.library.facepunch.libsdf, Version=0.0.116.0, Culture=neutral, PublicKeyToken=null' in the context '"IsolatedAssemblyContext" Sandbox.Internal.IsolatedAssemblyContext #9' in a byte array.)
{
  "_type": "component",
  "component_id": "18fcdcfa-5aa8-440a-b806-592601ed927a",
  "go": "08a72929-c2dd-4da0-b84d-fdca3b287389",
  "component_type": "Sdf2DWorld"
}    System.InvalidCastException: [A]Sandbox.Sdf.Sdf2DWorld cannot be cast to [B]Sandbox.Sdf.Sdf2DWorld. Type A originates from 'package.library.facepunch.libsdf, Version=0.0.116.0, Culture=neutral, PublicKeyToken=null' in the context '"IsolatedAssemblyContext" Sandbox.Internal.IsolatedAssemblyContext #13' in a byte array. Type B originates from 'package.library.facepunch.libsdf, Version=0.0.116.0, Culture=neutral, PublicKeyToken=null' in the context '"IsolatedAssemblyContext" Sandbox.Internal.IsolatedAssemblyContext #9' in a byte array.
   at Sandbox.JsonSerializedConvert`1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in C:\build\_work\sbox\sbox\engine\Sandbox.Engine\Utility\Json\IJsonConvert.cs:line 39
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.DeserializeAsObject(Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromNodeAsObject(JsonNode node, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize(JsonNode node, Type returnType, JsonSerializerOptions options)
   at Sandbox.Json.FromNode(JsonNode node, Type type) in C:\build\_work\sbox\sbox\engine\Sandbox.Engine\Utility\Json\Json.cs:line 190
   at Sandbox.Component.DeserializeProperty(MemberDescription member, JsonNode node) in C:\build\_work\sbox\sbox\engine\Sandbox.Game\Scene\Components\Component.Serialize.cs:line 233
   at Sandbox.Component.PostDeserialize() in C:\build\_work\sbox\sbox\engine\Sandbox.Game\Scene\Components\Component.Serialize.cs:line 167

This seems to cause the SdfWorld component to fail to be created on the clients, which is detrimental if the host needs to change and take over the object with the SdfWorld.

To Reproduce

  1. Open Grubs (outside of editor)
  2. Join with a second instance
  3. Observer serialization error. If the host leaves, the SdfWorld is null and the game breaks.

Expected behavior

Component is created and gets transferred successfully.

Media/Files

No response

Additional context

No response

@trundlr
Copy link
Author

trundlr commented Jan 5, 2025

btw: this issue seemed to occur both on the current version of Grubs, and on an old version from back in September. This leads me to believe it was an engine change that caused this issue, and not any recent Grubs changes (however, I am not sure how libraries and game versions are bundled together)

Log from the September build of Grubs for posterity:

2025/01/05 00:35:35.1139	[GameMenu] Error when deserializing GrubsTerrain on (Terrain).SdfWorld ([A]Sandbox.Sdf.Sdf2DWorld cannot be cast to [B]Sandbox.Sdf.Sdf2DWorld. Type A originates from 'package.library.facepunch.libsdf, Version=0.0.116.0, Culture=neutral, PublicKeyToken=null' in the context '"IsolatedAssemblyContext" Sandbox.Internal.IsolatedAssemblyContext #14' in a byte array. Type B originates from 'package.library.facepunch.libsdf, Version=0.0.116.0, Culture=neutral, PublicKeyToken=null' in the context '"IsolatedAssemblyContext" Sandbox.Internal.IsolatedAssemblyContext #9' in a byte array.)
{
  "_type": "component",
  "component_id": "18fcdcfa-5aa8-440a-b806-592601ed927a",
  "go": "08a72929-c2dd-4da0-b84d-fdca3b287389",
  "component_type": "Sdf2DWorld"
}	System.InvalidCastException: [A]Sandbox.Sdf.Sdf2DWorld cannot be cast to [B]Sandbox.Sdf.Sdf2DWorld. Type A originates from 'package.library.facepunch.libsdf, Version=0.0.116.0, Culture=neutral, PublicKeyToken=null' in the context '"IsolatedAssemblyContext" Sandbox.Internal.IsolatedAssemblyContext #14' in a byte array. Type B originates from 'package.library.facepunch.libsdf, Version=0.0.116.0, Culture=neutral, PublicKeyToken=null' in the context '"IsolatedAssemblyContext" Sandbox.Internal.IsolatedAssemblyContext #9' in a byte array.
   at Sandbox.JsonSerializedConvert`1.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options) in C:\build\_work\sbox\sbox\engine\Sandbox.Engine\Utility\Json\IJsonConvert.cs:line 39
   at System.Text.Json.Serialization.JsonConverter`1.TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, T& value, Boolean& isPopulatedValue)
   at System.Text.Json.Serialization.JsonConverter`1.ReadCore(Utf8JsonReader& reader, T& value, JsonSerializerOptions options, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.Deserialize(Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1.DeserializeAsObject(Utf8JsonReader& reader, ReadStack& state)
   at System.Text.Json.JsonSerializer.ReadFromNodeAsObject(JsonNode node, JsonTypeInfo jsonTypeInfo)
   at System.Text.Json.JsonSerializer.Deserialize(JsonNode node, Type returnType, JsonSerializerOptions options)
   at Sandbox.Json.FromNode(JsonNode node, Type type) in C:\build\_work\sbox\sbox\engine\Sandbox.Engine\Utility\Json\Json.cs:line 190
   at Sandbox.Component.DeserializeProperty(MemberDescription member, JsonNode node) in C:\build\_work\sbox\sbox\engine\Sandbox.Game\Scene\Components\Component.Serialize.cs:line 233
   at Sandbox.Component.PostDeserialize() in C:\build\_work\sbox\sbox\engine\Sandbox.Game\Scene\Components\Component.Serialize.cs:line 167

@Metapyziks Metapyziks self-assigned this Jan 5, 2025
@Metapyziks Metapyziks moved this from To triage to Backlog in s&box tracker Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

2 participants