mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
fix: NetworkServer.BroadcastToConnectio can now recover from null entries instead of slowing down perf with log messages forever [credits: BigBoxVR/CF]
This commit is contained in:
parent
0cb777d3dd
commit
c77d8459fb
@ -1870,6 +1870,7 @@ static NetworkWriter SerializeForConnection(NetworkIdentity identity, NetworkCon
|
||||
static void BroadcastToConnection(NetworkConnectionToClient connection)
|
||||
{
|
||||
// for each entity that this connection is seeing
|
||||
bool hasNull = false;
|
||||
foreach (NetworkIdentity identity in connection.observing)
|
||||
{
|
||||
// make sure it's not null or destroyed.
|
||||
@ -1895,10 +1896,18 @@ static void BroadcastToConnection(NetworkConnectionToClient connection)
|
||||
// always call Remove in OnObjectDestroy everywhere.
|
||||
// if it does have null then someone used
|
||||
// GameObject.Destroy instead of NetworkServer.Destroy.
|
||||
else Debug.LogWarning($"Found 'null' entry in observing list for connectionId={connection.connectionId}. Please call NetworkServer.Destroy to destroy networked objects. Don't use GameObject.Destroy.");
|
||||
else
|
||||
{
|
||||
hasNull = true;
|
||||
Debug.LogWarning($"Found 'null' entry in observing list for connectionId={connection.connectionId}. Please call NetworkServer.Destroy to destroy networked objects. Don't use GameObject.Destroy.");
|
||||
}
|
||||
}
|
||||
|
||||
// recover from null entries.
|
||||
// otherwise every broadcast will spam the warning and slow down performance until restart.
|
||||
if (hasNull) connection.observing.RemoveWhere(identity => identity == null);
|
||||
}
|
||||
|
||||
// helper function to check a connection for inactivity and disconnect if necessary
|
||||
// returns true if disconnected
|
||||
static bool DisconnectIfInactive(NetworkConnectionToClient connection)
|
||||
|
Loading…
Reference in New Issue
Block a user