-
-
Notifications
You must be signed in to change notification settings - Fork 206
Description
General
Unity version: 2022.3.22f1
Fish-Networking version: 4.6.2
Discord link: https://discord.com/channels/424284635074134018/923983677980045382/1347684214363000832
Description
When I use a predict spawn a ReadPayload is called on the spawned object with an invalid payload on client owner of the spawn. I mean the payload doesn't match with what I write in the WritePayload function. After an investigation the payloadLength in ManagedObjects.Spawning.cs line 465 seems corrupted, I get sometime negative or huge values (-1828650512, 1308688880, -234814992).
Replication
Steps to reproduce the behavior:
- Add Debug.Log(payloadLength.Value) in ManagedObjects.Spawning.cs line 466
- Call a predict spawn (without pool in my case)
- Look the console log on the client owner of the spawn and notice the value, it's invalid (negative or huge values like -1828650512, 1308688880, -234814992).
Expected behavior
ReadPayload matching with WritePayload.
Screenshots
I believe I found a fix

We need to add payload.Count (or segmentReader.Length) in last parameter of ReadPayload called in ClientObject.cs line 423 because this function believes the length is in the segmentReader and will read the first bytes of the payload instead. When the value is positive the following code is executed with an offseted reader giving a corrupted payload.