Skip to content

Commit ae16e8c

Browse files
author
Josie Messa
authored
Only track one metric for scene sync and do not report scene name (#1159)
Previously we were tracking all scenes that were included in the message when an S2C_Sync message was sent or received. Now we have a better understanding of this scene event type, this feels like the wrong level of detail for this metric so we are now just reporting the scene event type and not the specific scenes. This will also make this metric consistent for C2S_SyncComplete where the scene names is not a core part of the message (the important thing is the event type itself and the number of network objects synced, not the scenes themselves). Similarly, S2C_Resync will not report each scene name, to keep consistent with the rest of the scene flow.
1 parent 97abc43 commit ae16e8c

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

com.unity.netcode.gameobjects/Runtime/SceneManagement/NetworkSceneManager.cs

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,11 +1188,8 @@ internal void SynchronizeNetworkObjects(ulong clientId)
11881188
ClientSynchEventData.OnWrite(nonNullContext.NetworkWriter);
11891189

11901190
var size = bufferSizeCapture.StopMeasureSegment();
1191-
foreach (var sceneIndex in ClientSynchEventData.ScenesToSynchronize)
1192-
{
1193-
m_NetworkManager.NetworkMetrics.TrackSceneEventSent(
1194-
clientId, (uint)ClientSynchEventData.SceneEventType, ScenesInBuild[(int)sceneIndex], size);
1195-
}
1191+
m_NetworkManager.NetworkMetrics.TrackSceneEventSent(
1192+
clientId, (uint)ClientSynchEventData.SceneEventType, "", size);
11961193
}
11971194

11981195
// Notify the local server that the client has been sent the SceneEventData.SceneEventTypes.S2C_Event_Sync event
@@ -1538,23 +1535,8 @@ internal void HandleSceneEvent(ulong clientId, Stream stream)
15381535
SceneEventData.OnRead(reader);
15391536
NetworkReaderPool.PutBackInPool(reader);
15401537

1541-
if (SceneEventData.SceneEventType == SceneEventData.SceneEventTypes.S2C_Sync)
1542-
{
1543-
// For this event the server may be sending scene event data about multiple scenes, so we need
1544-
// to track a metric for each one.
1545-
foreach (var sceneIndex in SceneEventData.ScenesToSynchronize)
1546-
{
1547-
m_NetworkManager.NetworkMetrics.TrackSceneEventReceived(
1548-
clientId, (uint)SceneEventData.SceneEventType, ScenesInBuild[(int)sceneIndex], stream.Length);
1549-
}
1550-
}
1551-
else
1552-
{
1553-
// For all other scene event types, we are only dealing with one scene at a time, so we can read it
1554-
// from the SceneEventData directly.
1555-
m_NetworkManager.NetworkMetrics.TrackSceneEventReceived(
1556-
clientId, (uint)SceneEventData.SceneEventType, ScenesInBuild[(int)SceneEventData.SceneIndex], stream.Length);
1557-
}
1538+
m_NetworkManager.NetworkMetrics.TrackSceneEventReceived(
1539+
clientId, (uint)SceneEventData.SceneEventType, ScenesInBuild[(int)SceneEventData.SceneIndex], stream.Length);
15581540

15591541
if (SceneEventData.IsSceneEventClientSide())
15601542
{

0 commit comments

Comments
 (0)