I’m encountering issues in the Unity Transport package (0.4.1-preview.1) after having disconnects and new connections.
I am able to reproduce it with the NetCube sample. I made a Win-Client build, ran the server in Unity Editor, and launched clients and closed them and opened new ones.
With NetCube, if I limited it to only 1 client ever connected at a time, the problem was not reproducible. It seems to require having had a disconnect and then connecting a 2nd simultaneous client. In my own project, it is reproducible from 1 client connecting, disconnecting, and connecting again. The error and callstack are different from what happens in NetCube.
Reproduction Steps using NetCube:
- Launch standalone NetCube server
- Launch first NetCube client
- Launch second NetCube client
- Close second NetCube client
- Launch third NetCube client
Here is the error and callstack that gets spammed after this:
Transport error and callstack from NetCube repro
ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Unity.Networking.Transport.DataStreamReader.ReadBytes (System.Byte* data, System.Int32 length) (at Library/PackageCache/com.unity.transport@0.4.1-preview.1/Runtime/DataStream.cs:624)
Unity.Networking.Transport.DataStreamReader.ReadULong () (at Library/PackageCache/com.unity.transport@0.4.1-preview.1/Runtime/DataStream.cs:682)
Unity.NetCode.RpcSystem+RpcExecJob.Execute (Unity.Entities.ArchetypeChunk chunk, System.Int32 chunkIndex, System.Int32 firstEntityIndex) (at Library/PackageCache/com.unity.netcode@0.4.0-preview.1/Runtime/Rpc/RpcSystem.cs:215)
Unity.Entities.JobChunkExtensions+JobChunkProducer1[T].ExecuteInternal (Unity.Entities.JobChunkExtensions+JobChunkWrapper
1[T]& jobWrapper, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at Library/PackageCache/com.unity.entities@0.14.0-preview.18/Unity.Entities/IJobChunk.cs:363)
Unity.Entities.JobChunkExtensions+JobChunkProducer1[T].Execute (Unity.Entities.JobChunkExtensions+JobChunkWrapper
1[T]& jobWrapper, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at Library/PackageCache/com.unity.entities@0.14.0-preview.18/Unity.Entities/IJobChunk.cs:337)
This is from my own project, and the error comes from the ReliableSequenced pipeline code.
ReliableSequencedPipeline error and callstack output
ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Unity.Networking.Transport.DataStreamReader.ReadBytes (System.Byte* data, System.Int32 length) (at Library/PackageCache/com.unity.transport@0.4.1-preview.1/Runtime/DataStream.cs:624)
Unity.Networking.Transport.ReliableSequencedPipelineStage.Receive (Unity.Networking.Transport.NetworkPipelineContext& ctx, Unity.Networking.Transport.InboundRecvBuffer& inboundBuffer, Unity.Networking.Transport.NetworkPipelineStage+Requests& requests) (at Library/PackageCache/com.unity.transport@0.4.1-preview.1/Runtime/Pipelines/ReliableSequencedPipelineStage.cs:67)
Unity.Networking.Transport.NetworkPipelineProcessor.ProcessReceiveStage (System.Int32 stage, Unity.Networking.Transport.NetworkPipeline pipeline, System.Int32 internalBufferOffset, System.Int32 internalSharedBufferOffset, Unity.Networking.Transport.NetworkPipelineContext& ctx, Unity.Networking.Transport.InboundRecvBuffer& inboundBuffer, Unity.Collections.NativeList1[System.Int32]& resumeQ, System.Boolean& needsUpdate, System.Boolean& needsSendUpdate) (at Library/PackageCache/com.unity.transport@0.4.1-preview.1/Runtime/NetworkPipeline.cs:912) Unity.Networking.Transport.NetworkPipelineProcessor.ProcessReceiveStagesFrom (Unity.Networking.Transport.NetworkDriver driver, System.Int32 startStage, Unity.Networking.Transport.NetworkPipeline pipeline, Unity.Networking.Transport.NetworkConnection connection, Unity.Networking.Transport.InboundRecvBuffer buffer) (at Library/PackageCache/com.unity.transport@0.4.1-preview.1/Runtime/NetworkPipeline.cs:851) Unity.Networking.Transport.NetworkPipelineProcessor.Receive (Unity.Networking.Transport.NetworkDriver driver, Unity.Networking.Transport.NetworkConnection connection, Unity.Collections.NativeArray
1[T] buffer) (at Library/PackageCache/com.unity.transport@0.4.1-preview.1/Runtime/NetworkPipeline.cs:819)
Unity.Networking.Transport.NetworkDriver.AppendPacket (Unity.Networking.Transport.NetworkInterfaceEndPoint address, Unity.Networking.Transport.Protocols.UdpCHeader header, System.Int32 dataLen) (at Library/PackageCache/com.unity.transport@0.4.1-preview.1/Runtime/NetworkDriver.cs:1328)
Unity.Networking.Transport.NetworkPacketReceiver.AppendPacket (Unity.Networking.Transport.NetworkInterfaceEndPoint address, Unity.Networking.Transport.Protocols.UdpCHeader header, System.Int32 dataLen) (at Library/PackageCache/com.unity.transport@0.4.1-preview.1/Runtime/INetworkInterface.cs:25)
Unity.Networking.Transport.BaselibNetworkInterface+ReceiveJob.Execute () (at Library/PackageCache/com.unity.transport@0.4.1-preview.1/Runtime/BaselibNetworkInterface.cs:326)
Unity.Jobs.IJobExtensions+JobStruct`1[T].Execute (T& data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at :0)