-
-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
ReadPayload is called with an invalid payload on client when it uses a predict spawn #855
Comments
Did you have a project file to this? I assume this can only be tested when spawning as client only? |
Hello, I'm sorry, I dont have sample project for this. Yes you need just to predict spawn as client. Server can be host or not, we get the same issue. |
Hey! I was not able to replicate the issue. I tried with two clients and server, as well two clients and host, as well one client + host/server. Payload length has always returned 0 as expected. Here's my test project. Steps: |
Hello, sorry my description was probably not clear. I updated your sample with this code in ReadWritePayload.cs : ` public class ReadWritePayload : NetworkBehaviour
} I added the Debug.Log($"ReadPayload Length : {payloadLength}"); in ManagedObjects.Spawning.cs line 466. |
Thanks, I took a better look and your solution seems appropriate. The size was already parsed into the array segment thus can be passed into the ReadPayload method. I used your solution except modified to reader.Length for consistency reasons. This will be resolved in the next release. If you wanted to submit a PR for the fix to get credit please feel free to. |
Thanks you, it's OK. You can submit. |
- Fixed Beta SyncList NullReferenceException error (#850). - Improved List and Dictionary collection readers now take collections from caches first. - Fixed NetworkTransform setting Rigidbody/2D interpolation to none on owners. - Fixed server configuring NetworkTransform before there was an owner. - Added PreciseTick(uint) constructor to generate a PreciseTick with 0 subtick value. - Fixed ReadPayload data corruption (#855). - Improved DebugManager inspector. - Fixed UniversalTickSmoother conditionally providing excessively large adaptive interpolation values. - Added Reader.ReadStringAllocated. - Obsoleted Reader.ReadString. - Added DebugManager Validate Rpc Lengths to verify RPCs potentially corrupting data. - Added SceneProcessorBase.GetLastLoadedScene. - Fixed OnStopNetwork incorrectly invoking on clientHost when object despawned for client but not yet on server.
- Fixed Beta SyncList NullReferenceException error (#850). - Improved List and Dictionary collection readers now take collections from caches first. - Fixed NetworkTransform setting Rigidbody/2D interpolation to none on owners. - Fixed server configuring NetworkTransform before there was an owner. - Added PreciseTick(uint) constructor to generate a PreciseTick with 0 subtick value. - Fixed ReadPayload data corruption (#855). - Improved DebugManager inspector. - Fixed UniversalTickSmoother conditionally providing excessively large adaptive interpolation values. - Added Reader.ReadStringAllocated. - Obsoleted Reader.ReadString. - Added DebugManager Validate Rpc Lengths to verify RPCs potentially corrupting data. - Added SceneProcessorBase.GetLastLoadedScene. - Fixed OnStopNetwork incorrectly invoking on clientHost when object despawned for client but not yet on server. - Added New NetworkBehaviour template menu under Fish-Networking > Configuratoin, thanks Rain1950! (#851).
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:
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.
The text was updated successfully, but these errors were encountered: