-
-
Notifications
You must be signed in to change notification settings - Fork 201
Closed
Labels
Resolved Pending ReleaseIssue is resolved and will be available on the noted version.Issue is resolved and will be available on the noted version.
Description
This issue is related to the previously reported problem in
#948.
When NetworkTrafficStatistics is enabled, clients can receive replicate messages where sendingClient is null.
In NetworkBehaviour.Prediction.OnReplicateRpc, this results in a client-side NullReferenceException when accessing sendingClient.IsValid.
Environment
- Unity: 6.x
- FishNet: 4.6.12+
- Client prediction enabled
- NetworkTrafficStatistics enabled
Steps to Reproduce
- Enable NetworkTrafficStatistics in any FishNet demo scene
- Enable client prediction
- Start a server
- Start a client (ParrelSync / second editor)
- Trigger predicted movement or replication
- Observe client-side NullReferenceException
Observed Error
sendingClient is null in OnReplicateRpc, causing a NullReferenceException.
Expected Behavior
Network traffic statistics should not throw client-side exceptions.
Proposed Fix
Guard against a null sendingClient before accessing IsValid:
#if !UNITY_SERVER
if (_networkTrafficStatistics != null)
{
bool fromServer = sendingClient != null && sendingClient.IsValid;
_networkTrafficStatistics.AddInboundPacketIdData(
PacketId.Replicate,
GetRpcName(PacketId.Replicate, hash.Value),
reader.Position - readerPositionAfterDebug + Managing.Transporting.TransportManager.PACKETID_LENGTH,
gameObject,
asServer: fromServer
);
}
#endifNotes
- This resolves the client-side NRE
- Behavior is unchanged when
sendingClientis valid - Follow-up to StatisticsManager bandwidth monitor throws nullref on clients #948
Metadata
Metadata
Assignees
Labels
Resolved Pending ReleaseIssue is resolved and will be available on the noted version.Issue is resolved and will be available on the noted version.