Skip to content

Commit 5ae2429

Browse files
author
Unity Technologies
committed
com.unity.netcode@0.50.1-preview.19
## [0.50.1] - 2022-03-18 ### Added * Hybrid assemblies will not be included in DOTS Runtime builds. ### Changed * Changed: Tick systems (Initialization, Simulation, Presentation) are not created as part of the default client-server bootstrap for Hybrid and the Client and Server worlds are updated by the PlayerLoop instead. ### Fixed * Fixed an exception in `PhysicsWorldHistory` when enabling lag compensation. * Fixed a rare compile error when source generators found invalid data in the package cache. * Fixed issue that prevent systems been shown in System Hierarchy window. * Fixed an issue where RPCs could be lost in rare cases when sending too many of them. * Fix an incorrect overflow exception when pre-spawned or predicted spawned ghost serialize a subset of the fields. ## [0.50.0] - 2021-09-17 ### Added * Added new methods `GhostSpawnSystem.ConvertGhostToInterpolated` and `GhostSpawnSystem.ConvertGhostToPredicted` for switching the prediction mode of a ghost. The methods have an optional transition time parameter which when not zero will smoothly transition the visual transform from the old to the new state. * Made it possible for clients to on demand load ghost prefabs by setting `GhostCollectionPrefab.Loading` to `GhostCollectionPrefab.LoadingState.LoadingActive` while the prefab is being loaded. * Added the possibility to dynamically load new sub-scenes with pre-spawned ghosts at runtime, while the both server and client are in game. * Added the possibility for a client to have only a sub-set of scenes loaded in respect to the server. Client will be able to load / unload them on demand. Creating a singleton with a DisableAutomaticPrespawnSectionReporting component lets you disable the built-in sub-scene synchronisation and implement your own logic. Can be used to implement more complex streaming scenario or other special needs. * Support for FirstSendImportanceMultiplier, which can be used to artificially inflate the importance of new (to the client) ghosts. I.e. Allows all ghosts to be sent to the client quickly, even if MinSendImportance is high. * A DriverMigrationSystem to allow migration of a NetworkDriver and related Connection Entities. To see a working example look into the `WorldMigrationTests` * Netcode bootstrap can now handle ISystemBase systems. * The NetDbg will now auto-connect when you focus on it, or when it's first opened, unless you manually call disconnect. * It is now possible to send commands without setting the `CommandTargetComponent` if the `ICommandData` is on a ghost which is predicted, owned by the current connection and has `SupportAutoCommandTarget` enabled in the authoring component. `SupportAutoCommandTarget` will add a `AutoCommandTarget` component, the server can set the `Enabled` member to false to prevent commands from being sent. The `AutoCommandTarget` can be used to send commands for multiple entities. It is also possible to have multiple `ICommandData` on the same entity, both for `AutoCommandTarget` and `CommandTargetComponent`. * Added `ClientServerTickRate.MaxSimulationLongStepTimeMultiplier` which allows you to run server ticks with longer delta time instead of, or in addition to, running more ticks in a frame. * Added `ClientServerTickRate.SendSnapshotsForCatchUpTicks` to decide if the server should send snapshots for all ticks or just the last when it needs multiple ticks in a frame. The default is to only send snapshot for the last tick. ### Changed * Changed `GhostFieldAttribute.MaxSmoothingDistance` from `int` to `float` * Changed `ConnectionAcceptJob.debugPrefix` from `FixedString32` to `FixedString128` to account for longer world names. * Made sure despawning can handle large number of ghosts desapwning at the same time. This also reduces the bandwidth required to despawn, but can increase the latency of despawns if there is packet-loss. * UpdateInWorld renamed to UpdateInWorldAttribute * UpdateInWorld.TargetWorld enum move to Unity.NetCode namespace. * Client can now enter/exit from "in game" without the need to disconnect from the server. * Server can now stop streaming ghosts to all clients (exit from game), load a new scene/subscene and start streaming ghost again. * `GhostPredictionDebugSystem` only runs when NetDbg is connected and processes more errors in parallel to improve performance. * Use stopwatch instead of TimeSpan for dots-runtime portability * Improve the handling of ticks when applying ghost state to avoid errors about not having a state to roll back to. * Server is now responsible to assign to all the pre-spawned ghosts their unique id. * All types in the generated serialiser now use qualified names * Debug logging is implemented using com.unity.logging * Added validation check on the server side that verify the command target entity, when set, has a ICommandData buffer. * Fixed command age not updated on the server if a non null entity target is set but no command data buffer is present. That was causing problem on the clients that were constantly increasing the prediction loop count and dropping the frame rate. * Pre-spawned ghost entities are disabled during conversion and re-enabled at runtime after their baseline are initialised. This should prevent user code to modify components before the entities are ready and consequently avoiding pre-spawned ghost hash validation failures. * An error is reported if a fields in ICommandData/IRpcCommand or replicated fields in IComponentData/IBufferElement starts with the reserver prefix __GHOST or __COMMAND * Replaced the out-out `DisableLagCompensation` with an opt-in `LagCompensationConfig`. * Removed previously deperecated `GhostCollectionAuthoringComponent`. * Undeprecated `ConvertToClientServerEntity`. It was deprecated because the old source gen could no support runtime conversion of ghosts, that is not a problem in the new source generator. We still recommend using subscenes for everything involving ghosts. * `NetworkStreamCloseSystem` has been moved to `NetworkReceiveSystemGroup`. * Network connection entities now has `LinkedEntityGroup` which makes it easier to delete ghosts on disconnection in simple cases. * The `GhostAuthoringComponent` has a new checkbox for adding a `GhostOwnerComponent` to a ghost without additional authoring components. * SceneLoadingTests are not Editor only tests * Websocket's DebugWebSocket code fixed for il2cpp tests ### Fixed * Fixed GhostAuthoringEditor not showing the correct default variant assigned to a component. * Fixed memory leak. GhostVariantAssignmentCollection blob data not disposed. * Fixed issue with ghost variant cache. GhostComponentVariation attribute where collected only if the annotated struct was public. * Stale inputs are no longer stored in the input buffer on the server. This makes it more reliable to compare current input state to last frames state. * Avoid overflow in RTT calculation if reported processing time is greater than the calculated delta time * Fixed hash calculation for child entities * Fixed an inconsistency error thrown when registering a generic job with a generic RPC type by changing the accessibility of 'RpcCommandRequest.SendRpcData' from protected to public * Fixed wrong stats packet size that was causing random crashes. * Fix GhostStatsSystem try access a NetworkAckComponent singleton when it does not exists (client only) * Typo in GhostSnapshotValueULong that cause compilation error when an RPC contains unsigned long fields. * LogAssert.ignoreFailingMessages not reset to true, causing some failing tests not being reported. * IrrelevantImportanceDownScale is now guarded to not go below 1. * `SnapshotDataBuffer` and `SnapshotDynamicDataBuffer` now use `[InternalBufferCapacity(0)]`, which will reduce entity size in a chunk. * Compilation error due to generated serializer class trying to cast types without prepending the correct namespace. * Ghost gen fails with GhostCodeGen failed for fragment.. if you have a namespace, typename or field name start with double underscores. An error is actually reported if __GHOSTXXX__ or __COMMANDXXX__ keywords are present. * UX improvement when creating an invalid Ghost Authoring. * No error reported if an component implement multiple interfaces at the same time, causing generating code for the wrong one. * PacketLogger output files are now saved for standalone player in Application.consoleLogPath instead of current folder, causing errors in some platform/environment. * No compilation errors for missing assemblies references are reported anymore if the assembly that does not contains types which require code-generated serializers. * Overriding nested component in a prefab will be assigned correct GameObject reference ### Upgrade guide * TargetWorld enum is now part of the Unity.NetCode namespace. Find and replace all the `UpdateInWorld.TargetWorld` occurrences with `TargetWorld` and continue to keep the enum old value. * `DisableLagCompensation` no longer exists. If you were note using lag compensation you can remove it, if you were using lag compensation you must add a `LagCompensationConfig` in order for it to run. * `GhostCollectionAuthoringComponent` is now removed, see previous upgrade guide and the getting started doc page for information on what to do instead.
1 parent 89e236a commit 5ae2429

20 files changed

+204
-56
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# Changelog
22

3+
## [0.50.1] - 2022-03-18
4+
5+
### Added
6+
7+
* Hybrid assemblies will not be included in DOTS Runtime builds.
8+
9+
### Changed
10+
11+
* Changed: Tick systems (Initialization, Simulation, Presentation) are not created as part of the default client-server bootstrap for Hybrid and the Client and Server worlds are updated by the PlayerLoop instead.
12+
13+
### Fixed
14+
15+
* Fixed an exception in `PhysicsWorldHistory` when enabling lag compensation.
16+
* Fixed a rare compile error when source generators found invalid data in the package cache.
17+
* Fixed issue that prevent systems been shown in System Hierarchy window.
18+
* Fixed an issue where RPCs could be lost in rare cases when sending too many of them.
19+
* Fix an incorrect overflow exception when pre-spawned or predicted spawned ghost serialize a subset of the fields.
20+
21+
22+
323
## [0.50.0] - 2021-09-17
424

525
### Added

Editor/MultiplayerPlayModeWindow.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,6 @@ protected override void OnUpdate()
275275
}
276276
}
277277

278-
#if !UNITY_SERVER
279-
[UpdateBefore(typeof(TickClientSimulationSystem))]
280-
#endif
281-
#if !UNITY_CLIENT || UNITY_SERVER || UNITY_EDITOR
282-
[UpdateBefore(typeof(TickServerSimulationSystem))]
283-
#endif
284278
[UpdateInWorld(TargetWorld.Default)]
285279
public partial class MultiplayerPlayModeControllerSystem : SystemBase
286280
{

Runtime/ClientServerWorld/ClientInitializationSystemGroup.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@ protected override void OnDestroy()
1313
{
1414
if (ParentTickSystem != null)
1515
ParentTickSystem.RemoveSystemFromUpdateList(this);
16+
#if !UNITY_DOTSRUNTIME
17+
ScriptBehaviourUpdateOrder.RemoveWorldFromCurrentPlayerLoop(World);
18+
#endif
1619
}
1720
#endif
1821
}
1922

2023
#if !UNITY_SERVER
24+
#if !UNITY_DOTSRUNTIME
25+
[DisableAutoCreation]
26+
#endif
2127
[UpdateInGroup(typeof(InitializationSystemGroup))]
2228
[AlwaysUpdateSystem]
2329
[UpdateInWorld(TargetWorld.Default)]
@@ -34,4 +40,4 @@ protected override void OnDestroy()
3440
}
3541
}
3642
#endif
37-
}
43+
}

Runtime/ClientServerWorld/ClientPresentationSystemGroup.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ protected override void OnUpdate()
2424
}
2525

2626
#if !UNITY_SERVER
27+
#if !UNITY_DOTSRUNTIME
28+
[DisableAutoCreation]
29+
#endif
2730
[UpdateInGroup(typeof(PresentationSystemGroup))]
2831
[AlwaysUpdateSystem]
2932
[UpdateInWorld(TargetWorld.Default)]
@@ -40,4 +43,4 @@ protected override void OnDestroy()
4043
}
4144
}
4245
#endif
43-
}
46+
}

Runtime/ClientServerWorld/ClientServerBootstrap.cs

Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,13 @@ public virtual void CreateDefaultClientServerWorlds(World defaultWorld)
7474
{
7575
PlayType playModeType = RequestedPlayType;
7676
int numClientWorlds = 1;
77-
7877
int totalNumClients = numClientWorlds;
78+
79+
if (playModeType == PlayType.Server || playModeType == PlayType.ClientAndServer)
80+
{
81+
CreateServerWorld(defaultWorld, "ServerWorld");
82+
}
83+
7984
if (playModeType != PlayType.Server)
8085
{
8186
#if UNITY_EDITOR
@@ -94,11 +99,6 @@ public virtual void CreateDefaultClientServerWorlds(World defaultWorld)
9499
}
95100
#endif
96101
}
97-
98-
if (playModeType != PlayType.Client)
99-
{
100-
CreateServerWorld(defaultWorld, "ServerWorld");
101-
}
102102
}
103103

104104
private static void AddSystemsToList(List<Type> src, List<Type> allManagedSystems, List<Type> allUnmanagedSystems)
@@ -124,11 +124,11 @@ public static World CreateClientWorld(World defaultWorld, string name, World wor
124124
var initializationGroup = world.GetOrCreateSystem<ClientInitializationSystemGroup>();
125125
var simulationGroup = world.GetOrCreateSystem<ClientSimulationSystemGroup>();
126126
var presentationGroup = world.GetOrCreateSystem<ClientPresentationSystemGroup>();
127-
128-
//Pre-create also all the necessary tick systems in the DefaultWorld
129-
var initializationTickSystem = defaultWorld.GetOrCreateSystem<TickClientInitializationSystem>();
130-
var simulationTickSystem = defaultWorld.GetOrCreateSystem<TickClientSimulationSystem>();
131-
var presentationTickSystem = defaultWorld.GetOrCreateSystem<TickClientPresentationSystem>();
127+
//These system are always created for dots-runtime automatically as part of the default world initialization.
128+
//In hybrid, they must be explicitly added to system list and they are only used for tests purpose.
129+
var initializationTickSystem = defaultWorld.GetExistingSystem<TickClientInitializationSystem>();
130+
var simulationTickSystem = defaultWorld.GetExistingSystem<TickClientSimulationSystem>();
131+
var presentationTickSystem = defaultWorld.GetExistingSystem<TickClientPresentationSystem>();
132132

133133
//Retrieve all clients systems and create all at once via GetOrCreateSystemsAndLogException.
134134
var allManagedTypes = new List<Type>(s_State.ClientInitializationSystems.Count +
@@ -210,12 +210,24 @@ public static World CreateClientWorld(World defaultWorld, string name, World wor
210210
presentationGroup.SortSystems();
211211

212212
//Bind main world group to tick systems (DefaultWorld tick the client world)
213-
initializationGroup.ParentTickSystem = initializationTickSystem;
214-
initializationTickSystem.AddSystemToUpdateList(initializationGroup);
215-
simulationGroup.ParentTickSystem = simulationTickSystem;
216-
simulationTickSystem.AddSystemToUpdateList(simulationGroup);
217-
presentationGroup.ParentTickSystem = presentationTickSystem;
218-
presentationTickSystem.AddSystemToUpdateList(presentationGroup);
213+
if (initializationTickSystem != null && simulationTickSystem != null && presentationTickSystem != null)
214+
{
215+
initializationGroup.ParentTickSystem = initializationTickSystem;
216+
initializationTickSystem.AddSystemToUpdateList(initializationGroup);
217+
simulationGroup.ParentTickSystem = simulationTickSystem;
218+
simulationTickSystem.AddSystemToUpdateList(simulationGroup);
219+
presentationGroup.ParentTickSystem = presentationTickSystem;
220+
presentationTickSystem.AddSystemToUpdateList(presentationGroup);
221+
}
222+
else
223+
{
224+
#if UNITY_DOTSRUNTIME
225+
//These systems are mandatory
226+
throw new InvalidOperationException("TickClientInitializationSystem, TickClientSimulationSystem and TickClientPresentationSystem are missing");
227+
#else
228+
ScriptBehaviourUpdateOrder.AppendWorldToCurrentPlayerLoop(world);
229+
#endif
230+
}
219231

220232
if (AutoConnectPort != 0 && DefaultConnectAddress != NetworkEndPoint.AnyIpv4)
221233
{
@@ -238,10 +250,10 @@ public static World CreateServerWorld(World defaultWorld, string name, World wor
238250
var world = worldToUse!=null ? worldToUse : new World(name, WorldFlags.Game);
239251
var initializationGroup = world.GetOrCreateSystem<ServerInitializationSystemGroup>();
240252
var simulationGroup = world.GetOrCreateSystem<ServerSimulationSystemGroup>();
241-
242-
//Pre-create also all the necessary tick systems in the DefaultWorld
243-
var initializationTickSystem = defaultWorld.GetOrCreateSystem<TickServerInitializationSystem>();
244-
var simulationTickSystem = defaultWorld.GetOrCreateSystem<TickServerSimulationSystem>();
253+
//These system are always created for dots-runtime automatically as part of the default world initialization.
254+
//In hybrid, they must be explicitly added to system list and they are only used for tests purpose.
255+
var initializationTickSystem = defaultWorld.GetExistingSystem<TickServerInitializationSystem>();
256+
var simulationTickSystem = defaultWorld.GetExistingSystem<TickServerSimulationSystem>();
245257

246258
//Retrieve all clients systems and create all at once via GetOrCreateSystemsAndLogException.
247259
var allManagedTypes = new List<Type>(s_State.ServerInitializationSystems.Count +
@@ -304,11 +316,22 @@ public static World CreateServerWorld(World defaultWorld, string name, World wor
304316
simulationGroup.SortSystems();
305317

306318
//Bind main world group to tick systems (DefaultWorld tick the client world)
307-
initializationGroup.ParentTickSystem = initializationTickSystem;
308-
initializationTickSystem.AddSystemToUpdateList(initializationGroup);
309-
simulationGroup.ParentTickSystem = simulationTickSystem;
310-
simulationTickSystem.AddSystemToUpdateList(simulationGroup);
311-
319+
if (initializationTickSystem != null && simulationTickSystem != null)
320+
{
321+
initializationGroup.ParentTickSystem = initializationTickSystem;
322+
initializationTickSystem.AddSystemToUpdateList(initializationGroup);
323+
simulationGroup.ParentTickSystem = simulationTickSystem;
324+
simulationTickSystem.AddSystemToUpdateList(simulationGroup);
325+
}
326+
else
327+
{
328+
#if UNITY_DOTSRUNTIME
329+
//These systems are mandatory
330+
throw new InvalidOperationException("TickServerSimulationSystem and TickServerInitializationSystem are missing");
331+
#else
332+
ScriptBehaviourUpdateOrder.AppendWorldToCurrentPlayerLoop(world);
333+
#endif
334+
}
312335
if (AutoConnectPort != 0)
313336
world.GetExistingSystem<NetworkStreamReceiveSystem>().Listen(DefaultListenAddress.WithPort(AutoConnectPort));
314337

Runtime/ClientServerWorld/ClientSimulationSystemGroup.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ protected override void OnUpdate()
9696
#if !UNITY_SERVER
9797
#if !UNITY_CLIENT || UNITY_SERVER || UNITY_EDITOR
9898
[UpdateAfter(typeof(TickServerSimulationSystem))]
99+
#endif
100+
#if !UNITY_DOTSRUNTIME
101+
[DisableAutoCreation]
99102
#endif
100103
[AlwaysUpdateSystem]
101104
[UpdateInWorld(TargetWorld.Default)]

Runtime/ClientServerWorld/ServerInitializationSystemGroup.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,20 @@ protected override void OnDestroy()
1313
{
1414
if (ParentTickSystem != null)
1515
ParentTickSystem.RemoveSystemFromUpdateList(this);
16+
#if !UNITY_DOTSRUNTIME
17+
//The playerloop is double buffered. However, becasue the ComponentSystemBase is a managed class
18+
//and the StatePtr is set to null, all the DummyWrapper instances will get called but will result in
19+
//an early return.
20+
ScriptBehaviourUpdateOrder.RemoveWorldFromCurrentPlayerLoop(World);
21+
#endif
1622
}
1723
#endif
1824
}
1925

2026
#if !UNITY_CLIENT || UNITY_SERVER || UNITY_EDITOR
27+
#if !UNITY_DOTSRUNTIME
28+
[DisableAutoCreation]
29+
#endif
2130
[UpdateInGroup(typeof(InitializationSystemGroup))]
2231
[AlwaysUpdateSystem]
2332
[UpdateInWorld(TargetWorld.Default)]
@@ -34,4 +43,4 @@ protected override void OnDestroy()
3443
}
3544
}
3645
#endif
37-
}
46+
}

Runtime/ClientServerWorld/ServerSimulationSystemGroup.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ void AdjustTargetFrameRate(int tickRate)
164164
}
165165

166166
#if !UNITY_CLIENT || UNITY_SERVER || UNITY_EDITOR
167+
#if !UNITY_DOTSRUNTIME
168+
[DisableAutoCreation]
169+
#endif
167170
[AlwaysUpdateSystem]
168171
[UpdateInWorld(TargetWorld.Default)]
169172
public class TickServerSimulationSystem : ComponentSystemGroup

Runtime/Gen/GeneratorShared.dll

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)