Skip to content

Commit 25d32f8

Browse files
author
Unity Technologies
committed
com.unity.netcode@1.3.6
## [1.3.6] - 2024-10-16 ### Changed * Improved XML document for `NetworkStreamDriver.ConnectionEventsForTick`. * Updated entities packages dependencies ### Fixed * an issue with netcode source generated files, causing multiple Burst.CompileAsync invocation, ending up in stalling the editor and the player for long time, and / or causing crashes. * Issue where `OverrideAutomaticNetcodeBootstrap` instances in scenes would be ignored in the Editor if 'Fast Enter Play-Mode Options' is disabled (i.e. when domain reloads triggered after clicking to enter play-mode). * Longstanding API documentation errors across Netcode for Entities API documentation.
1 parent 55e467f commit 25d32f8

File tree

65 files changed

+909
-478
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+909
-478
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,18 @@
22
uid: changelog
33
---
44

5-
# Changelog
5+
## [1.3.6] - 2024-10-16
66

7+
### Changed
8+
9+
* Improved XML document for `NetworkStreamDriver.ConnectionEventsForTick`.
10+
* Updated entities packages dependencies
11+
12+
### Fixed
13+
14+
* an issue with netcode source generated files, causing multiple Burst.CompileAsync invocation, ending up in stalling the editor and the player for long time, and / or causing crashes.
15+
* Issue where `OverrideAutomaticNetcodeBootstrap` instances in scenes would be ignored in the Editor if 'Fast Enter Play-Mode Options' is disabled (i.e. when domain reloads triggered after clicking to enter play-mode).
16+
* Longstanding API documentation errors across Netcode for Entities API documentation.
717

818
## [1.3.2] - 2024-09-06
919

Documentation~/playmode-tool.md

Lines changed: 63 additions & 41 deletions
Large diffs are not rendered by default.

Editor/Authoring/GhostComponentAnalytics.cs

Lines changed: 118 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Unity.NetCode.Analytics;
66
using Unity.Networking.Transport;
77
using UnityEditor;
8+
using UnityEditor.PackageManager;
89
using UnityEngine.Analytics;
910

1011
namespace Unity.NetCode.Editor
@@ -40,14 +41,12 @@ static GhostScaleAnalyticsData ComputeScaleData()
4041
{
4142
var data = new GhostScaleAnalyticsData
4243
{
43-
PlayerCount = NetCodeAnalyticsState.GetPlayerCount(),
4444
Settings = new PlaymodeSettings
4545
{
4646
ThinClientCount = MultiplayerPlayModePreferences.RequestedNumThinClients,
4747
SimulatorEnabled = MultiplayerPlayModePreferences.SimulatorEnabled,
4848
Delay = MultiplayerPlayModePreferences.PacketDelayMs,
4949
DropPercentage = MultiplayerPlayModePreferences.PacketDropPercentage,
50-
FuzzPercentage = MultiplayerPlayModePreferences.PacketFuzzPercentage,
5150
Jitter = MultiplayerPlayModePreferences.PacketJitterMs,
5251
PlayModeType = MultiplayerPlayModePreferences.RequestedPlayType.ToString(),
5352
SimulatorPreset = MultiplayerPlayModePreferences.CurrentNetworkSimulatorPreset
@@ -62,39 +61,6 @@ static GhostScaleAnalyticsData ComputeScaleData()
6261
var numServerWorlds = 0;
6362
foreach (var world in World.All)
6463
{
65-
void CollectMainClientData()
66-
{
67-
TryGetSingleton(world, out data.ClientTickRate);
68-
data.MainClientData.NumOfSpawnedGhost = CountSpawnedGhosts(world.EntityManager);
69-
TryGetSingleton(world, out data.ClientServerTickRate);
70-
71-
var spawnedGhostCount = CountSpawnedGhosts(world.EntityManager);
72-
TryGetSingleton<GhostRelevancy>(world, out var ghostRelevancy);
73-
using var predictedGhostQuery = world.EntityManager.CreateEntityQuery(ComponentType.ReadOnly<PredictedGhost>());
74-
var predictionCount = predictedGhostQuery.CalculateEntityCountWithoutFiltering();
75-
TryGetSingleton<PredictionSwitchingAnalyticsData>(world, out var predictionSwitchingAnalyticsData);
76-
data.MainClientData = new MainClientData
77-
{
78-
RelevancyMode = ghostRelevancy.GhostRelevancyMode,
79-
NumOfSpawnedGhost = spawnedGhostCount,
80-
NumOfPredictedGhosts = predictionCount,
81-
NumSwitchToInterpolated = predictionSwitchingAnalyticsData.NumTimesSwitchedToInterpolated,
82-
NumSwitchToPredicted = predictionSwitchingAnalyticsData.NumTimesSwitchedToPredicted,
83-
};
84-
}
85-
86-
void CollectServerData()
87-
{
88-
data.ServerSpawnedGhostCount = CountSpawnedGhosts(world.EntityManager);
89-
90-
data.GhostTypes = CollectGhostTypes(world.EntityManager);
91-
data.GhostTypeCount = data.GhostTypes.Length;
92-
93-
data.SnapshotTargetSize = TryGetSingleton<NetworkStreamSnapshotTargetSize>(world, out var snapshotTargetSize)
94-
? snapshotTargetSize.Value
95-
: NetworkParameterConstants.MaxMessageSize;
96-
}
97-
9864
var sent = NetCodeAnalyticsState.GetUpdateLength(world);
9965
if (sent > 0)
10066
{
@@ -118,6 +84,47 @@ void CollectServerData()
11884
}
11985
numMainClientWorlds++;
12086
}
87+
88+
continue;
89+
90+
void CollectServerData()
91+
{
92+
data.ServerSpawnedGhostCount = CountSpawnedGhosts(world.EntityManager);
93+
94+
data.GhostTypes = CollectGhostTypes(world.EntityManager);
95+
data.GhostTypeCount = data.GhostTypes.Length;
96+
97+
data.SnapshotTargetSize = TryGetSingleton<NetworkStreamSnapshotTargetSize>(world, out var snapshotTargetSize)
98+
? snapshotTargetSize.Value
99+
: NetworkParameterConstants.MaxMessageSize;
100+
}
101+
102+
void CollectMainClientData()
103+
{
104+
if (TryGetSingleton(world, out ClientTickRate clientTickRate))
105+
{
106+
data.ClientTickRate = new WrappedClientTickRate(clientTickRate);
107+
}
108+
data.MainClientData.NumOfSpawnedGhost = CountSpawnedGhosts(world.EntityManager);
109+
if (TryGetSingleton(world, out ClientServerTickRate clientServerTickRate))
110+
{
111+
data.ClientServerTickRate = new WrappedClientServerTickRate(clientServerTickRate);
112+
}
113+
114+
var spawnedGhostCount = CountSpawnedGhosts(world.EntityManager);
115+
TryGetSingleton<GhostRelevancy>(world, out var ghostRelevancy);
116+
using var predictedGhostQuery = world.EntityManager.CreateEntityQuery(ComponentType.ReadOnly<PredictedGhost>());
117+
var predictionCount = predictedGhostQuery.CalculateEntityCountWithoutFiltering();
118+
TryGetSingleton<PredictionSwitchingAnalyticsData>(world, out var predictionSwitchingAnalyticsData);
119+
data.MainClientData = new MainClientData
120+
{
121+
RelevancyMode = (int)ghostRelevancy.GhostRelevancyMode,
122+
NumOfSpawnedGhost = spawnedGhostCount,
123+
NumOfPredictedGhosts = predictionCount,
124+
NumSwitchToInterpolated = (int)predictionSwitchingAnalyticsData.NumTimesSwitchedToInterpolated,
125+
NumSwitchToPredicted = (int)predictionSwitchingAnalyticsData.NumTimesSwitchedToPredicted,
126+
};
127+
}
121128
}
122129

123130
if (amount == 0)
@@ -126,7 +133,7 @@ void CollectServerData()
126133
}
127134
else
128135
{
129-
data.AverageGhostInSnapshot = serializedSent / amount;
136+
data.AverageGhostInSnapshot = (int)(serializedSent / amount);
130137
}
131138
data.NumMainClientWorlds = numMainClientWorlds;
132139
data.NumServerWorlds = numServerWorlds;
@@ -211,6 +218,74 @@ public override string ToString()
211218
}
212219
}
213220

221+
/// <summary>
222+
/// This struct is used to wrap the <see cref="ClientServerTickRate"/> struct to be serializable.
223+
/// We ensure here that the data matches the expected format for the analytics.
224+
/// If you change this struct, you must also update the analytics event in schemata.
225+
/// </summary>
226+
[Serializable]
227+
internal struct WrappedClientServerTickRate
228+
{
229+
public int MaxSimulationStepBatchSize;
230+
public int MaxSimulationStepsPerFrame;
231+
public int NetworkTickRate;
232+
public int SimulationTickRate;
233+
public int TargetFrameRateMode;
234+
235+
public WrappedClientServerTickRate(ClientServerTickRate clientServerTickRate)
236+
{
237+
this.MaxSimulationStepBatchSize = clientServerTickRate.MaxSimulationStepBatchSize;
238+
this.MaxSimulationStepsPerFrame = clientServerTickRate.MaxSimulationStepsPerFrame;
239+
this.NetworkTickRate = clientServerTickRate.NetworkTickRate;
240+
this.SimulationTickRate = clientServerTickRate.SimulationTickRate;
241+
this.TargetFrameRateMode = (int)clientServerTickRate.TargetFrameRateMode;
242+
}
243+
}
244+
245+
/// <summary>
246+
/// This struct is used to wrap the <see cref="ClientTickRate"/> struct to be serializable.
247+
/// We ensure here that the data matches the expected format for the analytics.
248+
/// If you change this struct, you must also update the analytics event in schemata.
249+
/// </summary>
250+
[Serializable]
251+
internal struct WrappedClientTickRate
252+
{
253+
public int CommandAgeCorrectionFraction;
254+
public int InterpolationDelayCorrectionFraction;
255+
public int InterpolationDelayJitterScale;
256+
public int InterpolationDelayMaxDeltaTicksFraction;
257+
public int InterpolationTimeMS;
258+
public int InterpolationTimeNetTicks;
259+
public int InterpolationTimeScaleMax;
260+
public int InterpolationTimeScaleMin;
261+
public int MaxExtrapolationTimeSimTicks;
262+
public int MaxPredictAheadTimeMS;
263+
public int MaxPredictionStepBatchSizeFirstTimeTick;
264+
public int MaxPredictionStepBatchSizeRepeatedTick;
265+
public int PredictionTimeScaleMax;
266+
public int PredictionTimeScaleMin;
267+
public int TargetCommandSlack;
268+
269+
public WrappedClientTickRate(ClientTickRate clientTickRate)
270+
{
271+
this.CommandAgeCorrectionFraction = (int)clientTickRate.CommandAgeCorrectionFraction;
272+
this.InterpolationDelayCorrectionFraction = (int)clientTickRate.InterpolationDelayCorrectionFraction;
273+
this.InterpolationDelayJitterScale = (int)clientTickRate.InterpolationDelayJitterScale;
274+
this.InterpolationDelayMaxDeltaTicksFraction = (int)clientTickRate.InterpolationDelayMaxDeltaTicksFraction;
275+
this.InterpolationTimeMS = (int)clientTickRate.InterpolationTimeMS;
276+
this.InterpolationTimeNetTicks = (int)clientTickRate.InterpolationTimeNetTicks;
277+
this.InterpolationTimeScaleMax = (int)clientTickRate.InterpolationTimeScaleMax;
278+
this.InterpolationTimeScaleMin = (int)clientTickRate.InterpolationTimeScaleMin;
279+
this.MaxExtrapolationTimeSimTicks = (int)clientTickRate.MaxExtrapolationTimeSimTicks;
280+
this.MaxPredictAheadTimeMS = (int)clientTickRate.MaxPredictAheadTimeMS;
281+
this.MaxPredictionStepBatchSizeFirstTimeTick = clientTickRate.MaxPredictionStepBatchSizeFirstTimeTick;
282+
this.MaxPredictionStepBatchSizeRepeatedTick = clientTickRate.MaxPredictionStepBatchSizeRepeatedTick;
283+
this.PredictionTimeScaleMax = (int)clientTickRate.PredictionTimeScaleMax;
284+
this.PredictionTimeScaleMin = (int)clientTickRate.PredictionTimeScaleMin;
285+
this.TargetCommandSlack = (int)clientTickRate.TargetCommandSlack;
286+
}
287+
}
288+
214289
[Serializable]
215290
#if UNITY_2023_2_OR_NEWER
216291
struct GhostScaleAnalyticsData : IAnalytic.IData
@@ -219,13 +294,12 @@ struct GhostScaleAnalyticsData
219294
#endif
220295
{
221296
public PlaymodeSettings Settings;
222-
public int PlayerCount;
223297
public int ServerSpawnedGhostCount;
224298
public int GhostTypeCount;
225-
public uint AverageGhostInSnapshot;
299+
public int AverageGhostInSnapshot;
226300
public GhostTypeData[] GhostTypes;
227-
public ClientServerTickRate ClientServerTickRate;
228-
public ClientTickRate ClientTickRate;
301+
public WrappedClientServerTickRate ClientServerTickRate;
302+
public WrappedClientTickRate ClientTickRate;
229303
public MainClientData MainClientData;
230304
public int SnapshotTargetSize;
231305
public int NumMainClientWorlds;
@@ -235,7 +309,6 @@ public override string ToString()
235309
{
236310
var builder = new StringBuilder();
237311
builder.Append($"{nameof(Settings)}: {Settings}, " +
238-
$"{nameof(PlayerCount)}: {PlayerCount}, " +
239312
$"{nameof(ServerSpawnedGhostCount)}: {ServerSpawnedGhostCount}, " +
240313
$"{nameof(GhostTypeCount)}: {GhostTypeCount}, " +
241314
$"{nameof(AverageGhostInSnapshot)}: {AverageGhostInSnapshot}, " +
@@ -259,10 +332,10 @@ public override string ToString()
259332
[Serializable]
260333
struct MainClientData
261334
{
262-
public GhostRelevancyMode RelevancyMode;
335+
public int RelevancyMode;
263336
public int NumOfPredictedGhosts;
264-
public long NumSwitchToPredicted;
265-
public long NumSwitchToInterpolated;
337+
public int NumSwitchToPredicted;
338+
public int NumSwitchToInterpolated;
266339
public int NumOfSpawnedGhost;
267340

268341
public override string ToString()
@@ -282,7 +355,6 @@ struct PlaymodeSettings
282355
public bool SimulatorEnabled;
283356
public int Delay;
284357
public int DropPercentage;
285-
public int FuzzPercentage;
286358
public int Jitter;
287359
public string PlayModeType;
288360
public string SimulatorPreset;
@@ -293,7 +365,6 @@ public override string ToString()
293365
$"{nameof(SimulatorEnabled)}: {SimulatorEnabled}, " +
294366
$"{nameof(Delay)}: {Delay}, " +
295367
$"{nameof(DropPercentage)}: {DropPercentage}, " +
296-
$"{nameof(FuzzPercentage)}: {FuzzPercentage}, " +
297368
$"{nameof(Jitter)}: {Jitter}, " +
298369
$"{nameof(PlayModeType)}: {PlayModeType}, " +
299370
$"{nameof(SimulatorPreset)}: {SimulatorPreset}, ";
@@ -306,7 +377,7 @@ static class GhostComponentAnalytics
306377
public const int k_MaxItems = 1000;
307378
public const string k_VendorKey = "unity.netcode";
308379
public const string k_Scale = "NetcodeGhostComponentScale";
309-
public const int k_ScaleVersion = 2;
380+
public const int k_ScaleVersion = 3;
310381
public const int k_ConfigurationVersion = 1;
311382
public const string k_Configuration = "NetcodeGhostComponentConfiguration";
312383

Editor/Templates/GhostComponentSerializer.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ static internal GhostComponentSerializer.State GetState(ref SystemState state)
337337
var innerMarker = new Unity.Profiling.ProfilerMarker("__GHOST_NAME__");
338338
innerMarker.Begin();
339339
#endif
340-
SetupFunctionPointers(ref s_State, ref state);
340+
s_StateInitialized = SetupFunctionPointers(ref s_State, ref state);
341341
//TODO: DOTS-7926 we should understand why we have in some cases a StackOverflowException.
342342
//UNCOMMENT THIS LINE TO DEBUG IF A BIG COMPONENT MAY BE CAUSING A STACK OVERFLOW
343343
// const int maxSizeToAvoidStackOverflow = 4_500;
@@ -356,6 +356,7 @@ static internal GhostComponentSerializer.State GetState(ref SystemState state)
356356
}
357357
return s_State;
358358
}
359+
359360
private static bool s_StateInitialized;
360361
private static GhostComponentSerializer.State s_State;
361362

Runtime/Analytics/NetCodeAnalyticsState.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
11
#if UNITY_EDITOR
22
using System.Linq;
33
using Unity.Entities;
4-
using UnityEditor;
54
using UnityEngine.Assertions;
65

76
namespace Unity.NetCode.Analytics
87
{
98
internal static class NetCodeAnalyticsState
109
{
11-
const string NetCodePlayerCount = "netcode_player_count";
12-
public static void SetPlayerCount(int playerCount)
13-
{
14-
SessionState.SetInt(NetCodePlayerCount, playerCount);
15-
}
16-
17-
public static int GetPlayerCount()
18-
{
19-
return SessionState.GetInt(NetCodePlayerCount, 0);
20-
}
21-
2210
public static uint GetUpdateLength(World world)
2311
{
2412
if (!world.EntityManager.CanBeginExclusiveEntityTransaction())

Runtime/Authoring/DefaultVariantSystemBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ protected sealed override void OnUpdate()
164164
}
165165

166166
/// <summary>
167-
/// Implement this method by adding to the <param name="defaultVariants"></param> mapping your
167+
/// Implement this method by adding to the <paramref name="defaultVariants"/> mapping your
168168
/// default type->variant <see cref="Rule"/>.
169169
/// </summary>
170170
/// <param name="defaultVariants"></param>

Runtime/Authoring/DefaultVariantSystemGroup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ namespace Unity.NetCode
77
/// The system group OnCreate method finalizes the default mapping inside its own `OnCreate` method, by collecting from all the registered
88
/// <see cref="DefaultVariantSystemBase"/> systems the set of variant to use.
99
/// The order in which variants are set in the map is governed by the creation order (see <see cref="CreateAfterAttribute"/>, <see cref="CreateBeforeAttribute"/>).
10+
/// </summary>
1011
/// <remarks>
1112
/// The group is present in both baking and client/server worlds.
1213
/// </remarks>
13-
/// </summary>
1414
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation | WorldSystemFilterFlags.ClientSimulation |
1515
WorldSystemFilterFlags.ThinClientSimulation | WorldSystemFilterFlags.BakingSystem)]
1616
public partial class DefaultVariantSystemGroup : ComponentSystemGroup

Runtime/Authoring/GhostComponentVariation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ namespace Unity.NetCode
77
/// present in variant declaration.
88
/// The component variant can be assigned at authoring time using the GhostAuthoringComponent editor.</para>
99
/// <para>Note: This is incompatible with any type implementing <see cref="DontSupportPrefabOverridesAttribute"/>.</para>
10+
/// </summary>
1011
/// <remarks>
1112
/// When declaring a variant, all fields that should be serialized must be declared. Any missing field or new field
1213
/// not present in the original struct will not be serialized.
1314
/// </remarks>
14-
/// </summary>
1515
[AttributeUsage(AttributeTargets.Struct)]
1616
public class GhostComponentVariationAttribute : Attribute
1717
{

Runtime/Authoring/GhostFieldAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ public class GhostFieldAttribute : Attribute
3939
public bool Composite { get; set; } = false;
4040

4141
/// <summary>
42-
/// <inheritdoc cref="SmoothingAction"/>
4342
/// Default is <see cref="SmoothingAction.Clamp"/>.
4443
/// </summary>
44+
/// <inheritdoc cref="SmoothingAction"/>
4545
public SmoothingAction Smoothing { get; set; } = SmoothingAction.Clamp;
4646

4747
/// <summary>Allows you to specify a custom serializer for this GhostField using the <see cref="GhostFieldSubType"/> API.</summary>

Runtime/Authoring/GhostModifiers.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Unity.NetCode
88
{
99
/// <summary>
1010
/// Assign to every <see cref="GhostInstance"/>, and denotes which Ghost prefab version this component is allowed to exist on.
11-
/// <example>Use this to disable rendering components on the Server version of the Ghost.</example>
11+
/// Use this to disable rendering components on the Server version of the Ghost.
1212
/// If you cannot change the ComponentType, use the `GhostAuthoringInspectionComponent` to manually override on a specific Ghost prefab.
1313
/// </summary>
1414
[Flags]
@@ -71,7 +71,7 @@ public enum GhostSendType
7171
/// <para><b>Meta-data of a <see cref="ICommandData"/> component, denoting whether or not the server should replicate the
7272
/// input commands back down to clients.
7373
/// Configure via <see cref="GhostComponentAttribute"/>.</b></para>
74-
/// <para>Docs for ICommandData:<inheritdoc cref="ICommandData"/></para>
74+
/// <para>See the documentation for ICommandData:<see cref="ICommandData"/></para>
7575
/// </summary>
7676
[Flags]
7777
public enum SendToOwnerType

0 commit comments

Comments
 (0)