Hi there, I'm getting a number of MLAPI errors while building a SteamNetworkingSockets transport and I'd love some help.
The transport appears to be partially working. The host sometimes doesn't display one or the other player, and sometimes players lag badly. Seems to be luck of the draw.
I have a feeling I'm doing something like leaving old data in the send and receive buffers between events but I don't know enough about buffers in c# to intuit the answer.
IntPtr sendBuffer = Marshal.AllocHGlobal(65536);
IntPtr[] receiveBuffers = new IntPtr[1]; // given PollEvent returns a single NetworkEvent, it seems we can only handle one message at a time.
The number 65 is different every time. Always a uint8, so seems to be a byte out of place.
This one is caused by the last one:
OSXPlayer(Alices-MacBook-Air.local) NullReferenceException: Object reference not set to an instance of an object
at MLAPI.Messaging.RpcQueueContainer.AddQueueItemToInboundFrame (MLAPI.Messaging.RpcQueueContainer+QueueItemType qItemType, System.Single timeStamp, System.UInt64 sourceNetworkId, MLAPI.Serialization.NetworkBuffer message) [0x00050] in /Users/wgodfrey/code/unity/learning/MLAPI 03/Library/PackageCache/com.unity.multiplayer.mlapi@3e3aef6aa0/Runtime/Messaging/RpcQueue/RpcQueueContainer.cs:285
at MLAPI.Messaging.InternalMessageHandler.RpcReceiveQueueItem (System.UInt64 clientId, System.IO.Stream stream, System.Single receiveTime, MLAPI.Messaging.RpcQueueContainer+QueueItemType queueItemType) [0x00073] in /Users/wgodfrey/code/unity/learning/MLAPI 03/Library/PackageCache/com.unity.multiplayer.mlapi@3e3aef6aa0/Runtime/Messaging/InternalMessageHandler.cs:568
And finally
ArgumentException: Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.
System.Buffer.BlockCopy (System.Array src, System.Int32 srcOffset, System.Array dst, System.Int32 dstOffset, System.Int32 count) (at <695d1cc93cca45069c528c15c9fdd749>:0)
MLAPI.Messaging.RpcBatcher.ReceiveItems (MLAPI.Serialization.NetworkBuffer& messageBuffer, MLAPI.Messaging.RpcBatcher+ReceiveCallbackType receiveCallback, MLAPI.Messaging.RpcQueueContainer+QueueItemType messageType, System.UInt64 clientId, System.Single receiveTime) (at Library/PackageCache/com.unity.multiplayer.mlapi@3e3aef6aa0/Runtime/Messaging/RpcBatcher.cs:214)
MLAPI.NetworkManager.HandleIncomingData (System.UInt64 clientId, MLAPI.Transports.NetworkChannel networkChannel, System.ArraySegment`1[T] data, System.Single receiveTime, System.Boolean allowBuffer) (at Library/PackageCache/com.unity.multiplayer.mlapi@3e3aef6aa0/Runtime/Core/NetworkManager.cs:1042)
MLAPI.NetworkManager.HandleRawTransportPoll (MLAPI.Transports.NetworkEvent networkEvent, System.UInt64 clientId, MLAPI.Transports.NetworkChannel networkChannel, System.ArraySegment`1[T] payload, System.Single receiveTime) (at Library/PackageCache/com.unity.multiplayer.mlapi@3e3aef6aa0/Runtime/Core/NetworkManager.cs:875)
MLAPI.NetworkManager.OnNetworkEarlyUpdate () (at Library/PackageCache/com.unity.multiplayer.mlapi@3e3aef6aa0/Runtime/Core/NetworkManager.cs:683)
MLAPI.NetworkManager.NetworkUpdate (MLAPI.NetworkUpdateStage updateStage) (at Library/PackageCache/com.unity.multiplayer.mlapi@3e3aef6aa0/Runtime/Core/NetworkManager.cs:641)
MLAPI.NetworkUpdateLoop.RunNetworkUpdateStage (MLAPI.NetworkUpdateStage updateStage) (at Library/PackageCache/com.unity.multiplayer.mlapi@3e3aef6aa0/Runtime/Core/NetworkUpdateLoop.cs:148)
MLAPI.NetworkUpdateLoop+NetworkEarlyUpdate+<>c.<CreateLoopSystem>b__0_0 () (at Library/PackageCache/com.unity.multiplayer.mlapi@3e3aef6aa0/Runtime/Core/NetworkUpdateLoop.cs:171)
Sorry we currently don't have the bandwidth to help with custom transport implementation. I'd suggest asking on Forums or Discord if there are other community members who are interested in helping out.
Hi there, I'm getting a number of MLAPI errors while building a
SteamNetworkingSockets
transport and I'd love some help.The transport appears to be partially working. The host sometimes doesn't display one or the other player, and sometimes players lag badly. Seems to be luck of the draw.
I have a feeling I'm doing something like leaving old data in the send and receive buffers between events but I don't know enough about buffers in c# to intuit the answer.
Buffers are created like so, taken verbatim from https://github.com/rlabrecque/Steamworks.NET/issues/411#issuecomment-826115503:
The relevant
Send
code:The relevant
PollEvent
code:Any guidance on how to fix this would be appreciated.
These errors are occasionally appearing in both consoles:
The number
65
is different every time. Always a uint8, so seems to be a byte out of place.This one is caused by the last one:
And finally