Skip to content

ReadPayload is called with an invalid payload on client when it uses a predict spawn #855

@Navlyc

Description

@Navlyc

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:

  1. Add Debug.Log(payloadLength.Value) in ManagedObjects.Spawning.cs line 466
  2. Call a predict spawn (without pool in my case)
  3. 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
Image
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolved Pending ReleaseIssue is resolved and will be available on the noted version.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions