Releases: needle-mirror/com.unity.netcode
Releases · needle-mirror/com.unity.netcode
1.4.0
[1.4.0] - 2024-11-14
Added
- A togglable warning to display when the server is batching ticks.
- PhysicGroupRunMode property to the NetcodePhysicsConfigAuthoring to let the user configure when the predicted physics loop should run.
- PredictionLoopUpdateMode property to the ClientTickRate to let the user configure when the PredictionSimulationSystemGroup should update. In particular, it is allow now to have the prediction loop running all the time, regardless of the presence of predicted ghost.
GhostSendSystemData.MaxIterateChunks
, which denotes the maximum number of chunks theGhostSendSystem
will iterate over in a single tick, for a given connection, within a singleNetworkTickRate
snapshot send interval. It's an optimization in use-cases where you have many thousands of static ghosts (and thus hundreds of static chunks which are iterated over unnecessarily to find ones containing possible changes), but can lead to empty snapshots if set too low. Pairs well withMaxSendChunks
, and defaults to 0 (OFF) to avoid a behaviour change.- Many Unity Transport Package
NetworkConfigParameters
have been added to theNetCodeConfig
. They are ignored if using a custom driver, unless said driver calls the new static methodDefaultDriverBuilder.AddNetcodePackageNetworkConfigParameters
. ClientServerTickRate.SnapshotAckMaskCapacity
configures the length of the ack mask history (inServerTicks
). It is used by the snapshot system to determine whether or not a ghost has an acked baseline snapshot, and only queried when said chunk is attempting to be resent. Its new default (of 4096, up from 256) supports ~1.1 minutes (up from ~4.26 seconds) under default settings (i.e. assuming aSimulationTickRate
of 60Hz). Increasing this value further can protect against the aforementioned snapshot acking errors when sending tens of thousands of ghosts to an individual client connection.GhostAuthoringComponent.MaxSendRate
, which denotes the maximum possible send frequency (in Hz) for ghost chunks of this ghost prefab type. Note, however, that other factors (likeNetworkTickRate
, ghost instance count, the use of Static-Optimization vs Dynamic,Importance
, Importance-Scaling,DefaultSnapshotPacketSize
etc.) will determine the final send rate. UseMaxSendRate
to brute-force reduce the bandwidth consumption of your most impactful ghost types.GhostCountInstantiatedOnClient
andGhostCountReceivedOnClient
to theGhostCount
struct to differentiate ghosts which we have only received the data for, from fully instantiated ghosts (i.e. ghosts with entities). See deprecation entry andPendingSpawnPlaceholder
.- The
AutomaticThinClientWorldsUtility
class, which facilitates runtime creation (and management) of thin clients. It is available to user-code, and when inPlayType.Server
.
Changed
- The error for
NetworkProtocolVersion
mismatches will now better indicate what exactly went wrong, and what steps can be taken to resolve the error. - Incremental UI improvement to the
MultiplayerPlayModeWindow
netcode worlds display. The server now lists ghost counts (details in tooltip), the clientGhostCount
singleton is now available via hovering over the ping tooltip (as it's often something you want to know), and theDriverStore
drivers are now displayed consistently. - Re-enabled disabled LoadScenes_AllScenesShouldConnect and LoadScenes_NoScenesShouldLog tests randomly failing that were failing because of the CommandSendSystemGroup issue.
- Behaviour Breaking Change:
GhostSendSystemData.MaxSendChunks
no longer limits the max number of chunks to iterate over (i.e. query) - unlessGhostSendSystemData.MaxIterateChunks
is zero - as it no longer counts cancelled chunk snapshot writes towards its total. Therefore, useGhostSendSystemData.MaxIterateChunks
instead to denote that limit. This should lead to fewer emptier packets, particularly when used in conjunction with many static and irrelevant ghosts. - API & Behaviour Breaking Change: The netcode package
DefaultDriverConstructor
will now default to the transportsNetworkParameterConstants.SendQueueCapacity
andReceiveQueueCapacity
respectively (each512
), rather than our own package implementation ofmax(playerCount * 4, 64)
whereplayerCount
is an optional parameter defaulting to 0. This optional parameter has since been removed fromCreateServerNetworkDriver
andGetNetworkServerSettings
, but you can instead override them via theNetCodeConfig
additions (see entry). This prevents the common fatal error case when playtesting with higher player counts, and removes the most common need for a per-projectINetworkStreamDriverConstructor
, but is a small regression in memory consumption (~1.8MB) on both the client and the server, when using any built-inINetworkStreamDriverConstructor
. We recommend configuring them back to 64 if that previously did not cause any issues. - The verbose "Delta time was negative. To avoid undefined behaviour the frame is skipped." log has been moved behind
NetDebug.DebugLog
and re-worded. - Merged the two internal batched and unbatched
GatherGhostChunks
methods. Performance characteristics of both should be practically identical. - Placeholder ghosts are now given the name
GHOST-PLACEHOLDER-{ghostType}
to aid in debugging. - Copy editing and improvements to the Setting up client and server worlds section of the documentation.
- Behaviour Breaking Change: The client will now ignore the
HandshakeApprovalTimeoutMS
until it has completed theHandshake
phase, as it should respect this servers value, rather than assuming its own. Relatedly: Be aware that client worlds will not fetch theClientServerTickRate
values from aNetCodeConfig.Global
config, they will only accept values sent to it by the server during handshake. - Behaviour Breaking Change: The
AddCommandData
method will now reject inputs withInvalid
Tick values, preventing runtime exceptions in rare cases. - Behaviour Breaking Change: The
DefaultDriverConstructor
no longer removes the IPC driver whenRequestedPlayType == Server
, as thin clients can now be instantiated on DGS builds (assuming supported by user-code).
Deprecated
NetworkDriverInstance.simulatorEnabled
setter, as writing to it did not effectively enable and disable the simulator.- Behaviour Breaking Change:
GhostSendSystemData.MaxSendEntities
no longer functions, as it was somewhat misleading, and less precise thanMaxSendChunks
andMaxIterateChunks
. - Renamed
GetNetworkSettings
toGetNetworkClientSettings
. GhostCount.GhostCountOnClient
has been deprecated as it is ambiguous: Its value is the same as the newGhostCountReceivedOnClient
, but its tooltip incorrectly implied that it was theGhostCountInstantiatedOnClient
.
Fixed
MultiplayerPlayModeWindow
issue where the width of the server world buttons were erroneously causing a Horizontal Scrollbar. Also removed slightly excessive repainting.- Limitation preventing the
MultiplayerPlayModeWindow
from being resized when undocked. - CommandSendSystemGroup running systems when the current server tick is invalid, CommandSendPacketSystem (and other system potentially) throwing exceptions.
- an issue when using physics interpolation, causing graphical jitter on the replicated ghost when the physics system run on partial ticks.
- It is possible now to allow physics to run in the prediction loop even in case no predicted ghosts are present. This can be achieved by combining the PredictionLoopUpdateMode and PhysicGroupRunMode options.
- 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.
- Critical
GhostSendSystem
andGhostChunkSerializer
issue preventing ghosts from successfully acking their own previous snapshots, in cases where the next attempted resend of a ghost chunk exceeded 256 ticks (easily encountered when attempting to replicate thousands of ghosts to a single connection). Whenever a ghost chunk is unable to ack, larger deltas must be resent, and static optimization early-outing logic cannot be applied, causing unnecessary bandwidth and CPU consumption. While this issue did tend to stabilize over time, our initial fix is to increase this ack window considerably (seeClientServerTickRate.SnapshotAckMaskCapacity
entry). - Prevented the
GhostAuthoringInspectionComponent
from erroneously re-baking the ghost while the user is editing a property on said ghost prefab (applicable only when in 'Auto-Refresh' mode). MinSendImportance
no longer artificially delays the initial send of ghosts with low importance values (although this was mitigatable viaFirstSendImportanceMultiplier
).- Issue with ElapsedTime in server worlds where it could fall behind compared to InitializationSystemGroup's if the frame's deltaTime was going over MaxSimulationStepsPerFrame * MaxSimulationStepBatchSize settings. This changes the catch up behaviour server side. Previously, the server would skip ticks if batching wasn't enough while now it'll do its best to catchup on those missing ticks on the subsequent frames if time allows.
- Issue where Netcode's ElapsedTime could be ahead of the InitializationSystemGroup elapsed time in server worlds. It should now either always be equal to or slightly behind if not enough time has accumulated for a tick to execute.
- Issue where disconnecting while in the process of spawning prefabs raised the following error: "Found a ghost in the ghost map which does not have an entity connected to it. This can happen if you delete ghost entities on the client."
- Overzealous RPC validation error when broadcasting an RPC on the same frame as a disconnection.
- The
AutomaticThinClientWorldsUtility
now allows you to disable automatic in-editor thin client creation by setting `Boot...
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.3.2
[1.3.2] - 2024-09-06
Changed
- Updated entities packages dependencies
Added
- Significantly reduced bandwidth consumption of command packets (i.e. input packets), by a) converting the first command payload in each packet to use delta-compression against zero, b) by making the number of commands sent (per-packet) tied to the
TargetCommandSlack
, c) by delta-compressing the NetworkTicks using the assumed previous tick (which is a correct assumption in the common case), and d) by using a singlechangeBit
if the previous command is exactly the same. ClientTickRate.NumAdditionalCommandsToSend
is a new field allowing you to configure how many additional commands to send to the server in each command (i.e. input) packet.- Support for dumping input commands into the
NetDebugPacket
dump, helping users visualize and diagnose bandwidth consumption. Implement the optional, burst-compatible methodToFixedString
on your input components to see field data in your packet dumps, too. - A
NetworkSnapshotAck.CommandArrivalStatistics
struct, documenting (on the server, for each client) how many commands arrive, and how many commands arrive too late. These statistics can be used to inform and tweakTargetCommandSlack
andNumAdditionalCommandsToSend
. - Significantly expanded our automated test coverage for Lag Compensation. We now detect off-by-one-tick errors between the client and server's lag compensation resolutions.
LagCompensationConfig.DeepCopyDynamicColliders
(defaulting to true) andLagCompensationConfig.DeepCopyStaticColliders
(defaulting to false) configuration values, enabling you to control whether or not colliders are deep copied during world cloning, preventing runtime exceptions when querying historic worlds during Lag Compensation. Also see the specializedPhysicsWorldHistorySingleton.DeepCopyRigidBodyCollidersWhitelist
collection.
Changed
PhysicsWorldHistory
now clones collision worlds after theBuildPhysicsWorld
step for the givenServerTick
. This fixes an issue where theCollisionWorld
returned byGetCollisionWorldFromTick
is off-by-one on the server. It is now easier to reason about, as the data stored forServerTick
T now actually corresponds to theBuildPhysicsWorld
operation that occurred on tick T (rather than T-1, which was the previous behaviour). We strongly recommend having automated testing for lag compensation accuracy, as this may introduce a regression, and is therefore a minor breaking change.PhysicsWorldHistory
now deep copies dynamic colliders by default (see fix entry). Performance impact should be negligible.
Fixed
- Corrected
seealso
usage in XML package documentation. - Documentation improvements and clarifications on the following pages: command stream, ghost snapshots, spawning ghosts, logging, network connection, networked cube, prediction, and RPCs.
- Lag Compensation issue in the case where an Entity - hit by a query against a historic lag compensation
CollisionWorld
fetched viaGetCollisionWorldFromTick
- has since been deleted. The colliders of dynamic ghosts are now deep cloned by default, preventing the blob asset assertions which would have otherwise been encountered here. You can also opt-into copying static colliders via theLagCompensationConfig
orNetCodePhysicsConfig
authoring (although the recommendation is to instead query twice; once against static geometry exclusively, using the latest collision world, then again using the hit position of the static query, against lag compensated dynamic entities). - Issue where non-power-of-2 History Buffer sizes would return incorrect entries when
ServerTick
wraps around. - an issue with iOS and WebGL AOT, causing the player throwing exceptions while trying to initialize the Netcode generated ghost serializer function pointers. The issue is present when using Burst 1.8 and Unity 6.0+
- an issue with GhostGroup serialization, incorrectly accessing the wrong ghost prefab type in the GhostCollectionPrefab array.
- an issue with buffer serialization when using GhostGroup, causing memory stomping at runtime (and exception thrown in the editor), due to the fact the required size for storing the buffer in the snapshot was calculated incorrectly. The root cause was the incorrect index used to access the GhostCollectionPrefab collection.
1.2.4
[1.2.4] - 2024-08-14
Changed
- Updated entities packages dependencies
1.3.0-pre.4
[1.3.0-pre.4] - 2024-07-17
Added
- Optional UUID5GhostType property to the GhostCreation.Config struct, which allows you to provide your own unique UUID5 identifier when creating a ghost prefab at runtime, instead of relying on the auto-generated one (which uses the SHA1 of the ghost name).
- NetworkStreamDriver.ResetDriverStore to properly reset the NetworkDriverStore
Changed
- All Simulate component enable states are reset to using a job instead of doing that synchronously on the main thread. Reason for the change is the fact this was inducing a big stall at the end of the Prediction loop. However, the benefits is only visible when there are a large number of jobified workload.
- Corrected incorrect/missing CHANGELOG entries across many previous versions.
- Updated Burst dependency to version 1.8.16
- Unified Multiplayer Project settings.
- Moved menu items to a collective place to improve workflows. This removes the Multiplayer menu and integrates into common places Window, Assets/Create, right-click menus, etc.
- The dependency on Unity Transport has been updated to version 2.2.1
- Re-exposed
TryFindAutoConnectEndPoint
andHasDefaultAddressAndPortSet
, with small documentation updates. - ConcurrentDriverStore and NetworkDriverStore.Concurrent are now public and you can use the NetworkDriverStore.Concurrent in your jobs to send/receive data.
1.3.0-exp.1
[1.3.0-exp.1] - 2024-06-11
Added
- The Multiplayer PlayMode Tools Window now calls synchronous
Connect
andDisconnect
methods, and now shows theHandshake
connection step. Handshake occurs when the client connection has been accepted by the server, but said client is awaiting aNetworkId
assignment RPC from said server. - Possibility to optimise the ghost serialization and pre-serialization by registering a custom chunk serialization function pointer that will let users reason on a per-archetype and write the serialization code without requiring virtual methods (function pointer call indirection) and optimised for the use case.
- Further clarifications, minor improvements, and fixes to the PlayMode Tools Window.
DefaultRelevancyQuery
to specify general rules for relevancy without specifying it ghost by ghost.- Tooltips and additional info for the NetCodeConfig, supporting
ClientServerTickRate
,ClientTickRate
, andGhostSendSystemData
. - Method
EnablePacketLogging.LogToPacket
, allowing user-code to add custom events to the netcode per-connection packet dump. - An optional connection approval procedure so you can validate that a connection is allowed to connect before a network ID is assigned to it. Connection Approval requests can be sent by client to server via an IApprovalRpcCommand RPC. The server can validate the arbitrary payload included in the RPC. No other data is processed by the server until the connection is approved.
- More documentation on prediction, edge cases to be careful about, interpolation, compression, physics ghost setup checklist and the general update loop.
- Increased validation applied to RPC serialization (including better error logging). We now ensure their deserialized size is the expected number of bytes.
- Test coverage for
windowSize: 64
forReliableSequencedPipelineStage
. - PredictedSpawnedGhostRollbackToSpawnTick property to the GhostAuthoringComponent to allow predicted ghost spawned by client to rollback and re-simulate their state starting from their spawn tick, until the authoritative spawn has been received from the server. The rollback only occurs if the client receives new snapshots from server that contains at least one predicted ghost.
- Changed usage of NetworkParameterConstants.MTU to use user configurable NetworkParameterConstants.MaxMessageSize. This allows snapshot and command buffers to reference the correct value and scale buffers accordingly.
- Exposed
NetworkStreamDriver.DriverStore
andLastEndPoint
. - Copy-free accessors for
NetworkStreamDriver
instances (viaGetDriverInstanceRW
andGetDriverInstanceRO
) and underlying drivers (viaGetDriverRW
andGetDriverRO
), which are also now used internally. The struct copy originals have been weakly deprecated. - Support for serializing non-byte-aligned RPCs. I.e. You can now delta-compress RPC fields using the
IRpcCommandSerializer
by delta-compressing against hardcoded baseline values.
Changed
- Added the full type name of the RPC component to the RPC entity name (behind "NetcodeRPC_" prefix).
- The netcode RPC header size has now changed (from 9B to 5B per packet, plus either 10B or 4B per RPC, depending on
DynamicAssemblyList
). - The max size of a serialized RPC is now 8192 bytes (ushort.MaxValue bits), as we now send the bits written, to be able to validate that the exact number of bits were read in the
RpcSystem
. - Reduced bandwidth consumption of netcode's
RpcSetNetworkId
RPC payload. - Updated
com.unity.transport
dependency to version 2.2.0. - Fixed another issue with predicted ghosts spawned again inside the prediction loop, not rolling back to the backup or re-predicting from the spawn tick, after being initialized by the PredictedSpawnGhostSystem (because of command buffer delay), effectively mispredicting again the first full tick and subsequent partial, and making the backup also contain mispredicted information.
- Renamed
RpcSetNetworkId
toServerApprovedConnection
. - The servers
Handshake
process is no longer instantaneous, resulting in a few extra ticks being required (typically) before a connection can be fully established (approximately 7 ticks, up from 4). See bug fix entry. NetCodeConnectionEvent
s are now raised on the server for the protocol version handshake process (theConnectionState.State.Handshake
enum value). See bug fix entry.- Reduced bandwidth consumption of netcode's
NetworkProtocolVersion
RPC.
Removed
- NoScale function delegate.
Fixed
- Compile error when having both com.unity.netcode and com.unity.dedicated-server package together.
- Issue where disconnecting your own client (via a direct
Disconnect
call) would fail to recycle theNetworkId
component, and fail to dispose of the Entity. - We now also correctly report and clean-up stale connections. I.e. Connections that are entered into invalid states by user-code.
- Issue where the
CommandSendSystem
was attempting to send RPCs with stale connections. - some slow path in the normal ghost serialization that was causing many re-serialization of the same chunk, in case the chunk data was not fitting inside the temporary stream buffer. That was almost the norm in many cases, when the serialised entities are large enough (either because of the number of components or because of the size of them).
- NetworkStreamConnection now holds an accurate connection state right after the call to driver's Connect, instead of having to wait a frame to get it updated.
- Minor documentation issues.
- InvalidOperationException: cases where EntityManager is part of an exclusive transaction we skip gathering analytics for its world.
- Breaking change where NoScale function was removed.
- Issue where the
NetCodeDebugConfig
would not reset to theLogLevel
default (ofNotify
) if toggled ON, changed, then toggled OFF, during playmode. - Minor documentation errors and improving overall grammar.
- Issue where
NetCodeConfig.Global
did not load correctly on first boot, if not selected in the Project assets window. If you have a globalNetCodeConfig
set in your PreloadedAssets Project Setting, we'll also auto-upgrade your project, moving the save to Project Settings (viaNetCodeClientAndServerSettings
). - Negative network delta time will skip updating the system group.
NETCODE_NDEBUG
define compiler error, and related missing documentation.- Issue where two IInputComponentData with the same name but in different namespaces would result in conflicted generated code. Namespace is now taken into account for source gen.
- Network emulation tooltip clarification.
- Off-by-one error causing RPCs sent on the same tick as the
ProtocolVersion
RPC to be corrupted. - Language improvements to PredictedSimulationSystemGroup and ClientServerBootstrap.
- Performance problems with GhostCollectionSystem, with large number of prefabs.
- PredictedGhostSpawnSystem incorrectly set the offset for serialized buffer data inside the snapshot buffer, making that incompatible with the GhostUpdateSystem logic and causing wrong data potentially copied back to the entity buffer.
- An issue with preserialized ghost, that were stomping component data with incorrect values.
- an issue in GhostUpdateSystem that was incorrectly handling the GhostComponentAttribute.SendToOwner flag, causing during continuation and partial ticks replicated data being overwritten incorrectly for predicted ghosts.
- An issue due to structural changes, that was causing a large number of prediction step performed by the client due to the fact a given ghost could not continue the current prediction from the last full ticks (either partial ticks or another full tick) because the entity data could not be found anymore in the prediction history buffer.
- Issue where RPCs appeared on deleted connection entities, leading to user code runtime exceptions, where, occasionally, the
NetworkId
component could not be found on theReceiveRpcCommandRequest.SourceConnection
(as the connection was already disconnected). - the client was acknowledging to the server only the last received snapshot instead of the last 32 (this was used to defeat packet loss). This was affecting both the ability to correct use all the available baseline for delta compression, and multiple re-sending static optimized ghost.
- Rendering issue in
GhostAuthoringInspectionComponent
, causing UI to right-clip. - Defensive fix for other rendering issue in
GhostAuthoringInspectionComponent
, causing the Refresh and auto-refresh buttons to not appear correctly. - Fixed check to early release allocations in the case where a ghost chunk has been reused. We now correctly free these chunks, reducing allocated memory overhead on the server.
- Rotation glitch issue with prediction switching interpolation
- Issue where RTT calculation would be incorrectly high when first connecting, especially with high packet loss.
- Issue where running a netcode test would invalidate the
NetworkTimeSystem.TimestampMS
for subsequent play-mode runs, when Domain Reloads are disabled, leading to0±0
ping readout (and related issues). - an issue with predicted spawned ghost and enableable components state not being saved correctly in the snapshot buffer when the PredictedSpawnGhostRequest is processed and the entity initialized.
- an issue with pre-spawned ghost and enableable components state not being saved correctly in the predicted spawn baseline buffer.
- exception thrown by the
GhostPresentationGameObjectSystem
when an entity is destroyed. The system was accessing the trackedGameObject
list using an invalid index in cases where the removedGameObject
was the last element. - Exceptionally rare infinite loop crash in
SetupDataAndAvailableBaselines
. - an issue in the PredictedGhostHistorySystem, that was storing the backup of newly spawned ghost using the wrong ghost type and serializer. It was causing weird problem later in the GhostUpdateSystem, in case predi...
1.2.3
[1.2.3] - 2024-05-30
Changed
- Updated entities packages dependencies
1.2.1
[1.2.1] - 2024-04-26
Changed
- Updated Burst dependency to version 1.8.13
- Updated entities packages dependencies
1.2.0
[1.2.0] - 2024-03-22
Changed
*Release Preparation
1.2.0-pre.12
[1.2.0-pre.12] - 2024-02-13
Added
- Optimisations for the gather-ghost-chunk by batching function pointer calls and using a better hash map.
- BatchScaleImportanceDelegate, a new version of the importance scaling function that work in batches. It is not required to set both the ScaleImportance and the BatchScaleImportance function pointers. If the BatchScaleImportance is set, it is the preferred.
- TempStreamInitialSize, a new parameter in the GhostSendSystemData for tuning the initial size of the temporary buffer used by server to serialise ghosts. By default now the size is 8KB.
- AlwaysRelevantQuery to specify general rules for relevancy without specifying it ghost by ghost.
Changed
- StreamCompressionDataModel is passed as in parameter to avoid many copy every time a WriteXXX or ReadXXX was called.
- Updated Burst dependency to version 1.8.12
Fixed
- UI issue disallowing the user from enabling the Network Emulator utility when upgrading with a now-deprecated EditorPref value.
- an issue with pre-serialised ghosts, corrupting memory, crashing or copying wrong data into the snapshot buffer in certain conditions.
- avoided GC allocation and the costly Marshal.GetDelegateFromFunctionPointer every time an FunctionPointer.Invoke is called. This is done by using directly unmanaged function pointers. All this, compatible with Burst enabled/disabled at any time.
- lot of memory copies for loop invariants. This also reduced some SafetyChecks and costly operations.
- avoid costly re-serialization of the whole chunk when the temp buffer can't fit all the data. This is one of the biggest costs during the serialisation loop. By default now the buffer is 8KB that reduce this possibility almost to 0.
- Assigned InterpolationTick to always be equal ServerTick on the Server simulation (as stated in the summary for this parameter). Additionally the typos pointed out in the parameter summary were corrected.
- Issue where prespawn failed to initialize when relevancy list was updated before replicating internal prespawn ghosts.