fix: NetworkServerSystem OnTransportConnect/Data/Disconnect callbacks now check if server is active. fixes a bug where Transport Update would be called just after stopping, then NRE would be thrown because OnTransportDisconnect would still try to remove from connections which is already null.
fix: StopServer() now clears ownedPerConnection to fix a bug where StartServer()->ConnectClient()->StopServer()->StartServer would throw an exception about old entities
perf: BitReader/Writer now use NativeArray/NativeSlice instead of byte and ArraySegment to be burstable. Transport OnData() now uses NativeSlice too.
breaking: NetworkMessage messageId size increased to 2 bytes
feature: NetworkMessageMeta.GetId<T> for automated message ids
perf: NetworkMessage.De/Serialize parameter changed from IBitReader/Writer to BitReader/Writer to avoid runtime allocations when casting to interfaces
perf: Batching now always flushes at the end of the frame in order to minimize latency
breaking: removed libuv & LiteNetLib. use kcp/Telepathy instead, which are both stable & fast enough for DOTSNET
Transports: initialization moved to Start()/Connect()
kcp2k updated to V1.12
Network Loop: Process Incoming -> Update World -> Process Outgoing
adjusted Transports for Early / LateUpdate
adjusted NetworkServer/ClientSystem update order
adjusted Interest Management update order
fix: Quaternion Compression LargestAbsoluteComponentIndex wrong largest initialization
packages: updated to Burst 1.6.0 for apple silicon support
packages: updated latest .previews of remaining packages
BitWriter128: rewrite to use int directly instead of scratch
BitWriter128: allow setting .BitPosition from the outside
BitReader128: expose .BitPosition
TransportServerSystem.Disconnect return value changed to void because the bool wasn't used anywhere.
packages: burst updated to 1.4.8 verified
feature: configurable Timeout
allocations explained with comments (C# ReceiveFrom / IPEndPoint.GetHashCode)
fix: #17 KcpConnection.ReceiveNextReliable now assigns message default so it works in .net too
fix: Segment pool is not static anymore. Each kcp instance now has it's own Pool. fixes #18 concurrency issues
fix: Transport initializations moved from OnCreate to OnStartRunning. Fixes a bug where kcp server would always run with default configuration because SelectiveSystemAuthoring Awake() configuration is called AFTER OnCreate(). Fixes kcp not handling much bandwidth because CongestionWindow was always enabled, limiting send queue to send buffer copying to around 60 items per tick due to congestion control.
Disabled some log messages on startup
Upgrade to Unity 2020.3 LTS again
breaking: Snapshots (raw). replaces Broadcast systems. Prepares for NetworkComponents.
breaking: NetworkEntity renamed to NetworkIdentity because that's what it is
fix: PongServerSystem.OnUpdate() now calls base.OnUpdate() too. Fixes a bug where batched messages wouldn't be flushed in the Pong example.
NetworkServerSystem.Send(List) obsoleted. It was only used by InterestManagementSystem, and the implementation simply calls Send(message) for each list entry.
perf: InterestManagement uses Send(message) instead of Send(list). previously it would sort messages into a list, call Send(list), then Send(List) would call Send(message) for each list entry, which is redundant.
fix: Batch.lastSendTime is now initialized to current time so that first elapsed time calculation doesn't use "now - 0" which would always be a lot
fix: deadlock/crash when closing loop inside a uv_run call is now detected and an error is logged instead of allowing libuv to crash Unity.
added more tests
fix: Shutdown now clears nativeLookup after logging about them not being disposed. fixes a bug where if one test/session would miss disposing, the values would stay in there and make all future tests fail until the next domain reload.
fix: TcpStream.OnCloseHandle doesn't invalidate the handle before the OnClosed callback anymore
fix: libuv Transport OnLibuvServerClosed doesn't access the disposed handle's usertoken anymore. we get the connectionId before disposing now.
fix: libuv Transport loops are created/disposed only once in OnCreate/OnDestroy. we should not dispose a loop while events are being called from a loop's uv_run
fix: libuv Transport now Updates even if server/client are null. fixes ClientVoluntaryDisconnect test not passing because client.Disconnect()->uv_close callback would only be called in next loop update, which would never happen if we don't update after the client was disposed.
fix: libuv Transport doesn't manually dispose the handle in OnLibuvError anymore. libuv2k does it internally already, and calling it twice is actually not a good idea.
fix: libuv Transport manually dispose the handle in OnLibuvClosed anymore. libuv2k does it internally already, and calling it Dispose() instead of a Dispose() call is just a bad idea. potentially fixes memory/crash issues.
fix: libuv Transport OnLibuvError/Closed checks null before invoking OnDisconnected. fixes a bug where stopping the Editor while client and server are running would clean up loop -> call OnClosed -> DOTSNET already removed the Transport events but libuv Transport still tried to access them.
perf: BitReader uses fast method when copying 4 bytes, slow method otherwise.
perf: BitWriter uses fast method when copying 4 bytes, slow method otherwise.
NativeHandle major rewrite to improve C#<->C interface
Fixed several memory issues
Hugely simplified code
NativeHandle memory leaks are now detected on shutdown
fix: netId is now ulong again instead of uint to avoid situations where Version would be larger than 0xF too quickly (e.g. after a monster respawned 16 times). Added comment so this is never changed again.
perf: kcp2k V1.6
better recv/send window size defaults
show max send/recv rate in debug gui
lots of improvements
fix: KcpTransport uses OnCreate to set up kcp, and wraps the callbacks in lazy functions. fixes a bug where starting in headless would cause a NullReferenceException because Kcp OnStartRunning is called after Server OnStartRunning.
perf: ServerActiveSimulationSystemGroup foreach allocations removed by using for-int
perf: ClientConnectSimulationSystemGroup foreach allocations removed by using for-int
BitWriter: support buffer sizes that aren't multiples of 4 for convenience
perf: Bitpacking to compress values down to the bit. Use BitWriter.WriteUInt(level, 1, 60) to compress a level from range 1..60 down to only 6 bits.
perf: Batching on a per-connection basis for every send function. This is a lot easier than Send(NativeList) only batching. And it actually batches every Send, not just Send(NativeList).
perf: NetworkEntity.netId 4 bytes uint instead of 8 bytes ulong. Reduces 10k Benchmark bandwidth from 2.48 MB/s to 2.1 MB/s.
perf: NetworkMessage.GetId() 2 bytes ushort reduced to 1 byte. Reduces 10k Benchmark Bandwidth from 2.10 MB/s to 2.00 MB/s. 256 message ids should be enough for every project.
perf: NetworkServer/Client WrapHandler uses 'default' instead of new T() in combination with 'where T : struct' to avoid heavy allocations of 88 KB / frame in 10k benchmark.
Network/ServerClientSystem hooks into Transport events via += instead of = to not overwrite anyone else's hooks. Prepares for NetworkStatistics.
Transport.OnSend for statistics etc.
NetworkStatistics to measure bandwidth via NetworkServer/ClientStatisticsAuthoring components, see Benchmark example.
fix: NetworkClientSystem.OnTransportData now disconnects if it's called with an empty ArraySegment
Packages: Burst updated from 1.3.0 to 1.4.3 [verified]
perf: KcpTransport: use 'turbo mode' configuration as recommended by original kcp repository
breaking: automated NetworkMessage serialization reverted. Back to custom Serialize/Deserialize methods. We still keep <<messageId,amount,messages>> batching & bandwidth savings from Send(NativeArray). Prepares for Bitpacker and solves for Array serialization like https://github.com/vis2k/DOTSNET/issues/3 . Make sure to add Serialize/Deserialize methods to your NetworkMessages when upgrading.
kcp2k V1.2: smaller fixes, MaxMessageSize increased from 1200 bytes to 145KB
packages: Entities updated from 0.14.0 to 0.16.0
packages: Hybrid Renderer updated to 0.10.0
packages: Unity.Physics updated to 0.5.1
Upgraded to Unity 2020.1.16
fix: LiteNetLibServer/ClientTransport: IPv6 disabled again because it caused a SocketException when connecting
LiteNetLib updated to 0.9.4
LiteNetLib Transport: enable IPv6
libuv2k V0.15: removed send/recv allocations, IL2CPP support, no more ConcurrentPool, fixed potential WriteRequest.Release deadlock
perf: BruteForceInterestManagement update time is now set in RebuildAll instead of Update. Avoids unnecessary updates if someone just called RebuildAll anyway
libuv2k V0.12: fixes, perf, libuv binaries bumped to V1.39.0, windows release build to fix DllNotFoundException
breaking: Apathy Transport replaced by libuv2k everywhere because it’s better in every single way (performance, stability, architecture, etc.)
NetworkClientSystem: OnConnected/OnDisconnected virtual functions added for classes that inherit from NetworkClientSystem
NetworkServerSystem: OnConnected/OnDisconnected virtual functions added for classes that inherit from NetworkServerSystem
fix: ChatClientSystem uses OnDisconnected instead of OnStartRunning to reset state. fixes issue 25 (note: works with MemoryTransport, doesn't work with Apathy yet because OnDisconnect isn't called on client for some reason)
fix: Apathy updated to V1.16. Fixes a bug where calling client.Disconnect() voluntarily would never call Transport.OnDisconnected.
NetworkTransformAuthoring component instead of auto generated. Make sure to reassign it on your prefabs and reassign sync direction. This was needed for some workflows.
Upgraded to Unity 2020.1 for latest ECS package updates
Packages: Entities updated to 0.13.0
Packages: HybridRenderer updated to 0.7.0 to fix errors
Packages: Unity.Physics updated to 0.4.1
sharp_uv updated to 0.5 to fix Unsafe is now internal error introduced by HybridRenderer 0.7.0
Quaternion compression to significantly reduce bandwidth. Apathy can now send 20k networked entities to a single connection easily without buffers getting full
Upgraded to Unity 2019.4.4f1
fix: HybridRenderer V2 can only be added to one world, otherwise we get 'material registered twice' errors. Bootstrap now only adds it to the client world.
fix: Bootstrap adds Companion systems to unitySystems
fix: DestroyAllNetworkEntities now works for Entities with LinkedEntityGroups too
fix: Apathy updated to V1.15. fixes iOS XCode build errors
New server->client message protocol to optimize bandwidth/performance
Message Packing for giant performance improvements for all transports:
NetworkServerSystem.Send(connectionId, NativeList) for high performance message sending with automated chunking to respect Transport MaxMessageSize
NetworkTransformServerSystem uses Send(NativeList) for high performance
InterestManagementSystem uses Send(NativeList) for high performance
Apathy Server Transport: send queueing removed because DOTSNET handles it
Libuv Server Transport: send queueing removed because DOTSNET handles it
fix: LiteNetLib Transport uses correct MTU to avoid TooBigPacketException when packing messages
Apathy Transport: NoDelay = true by default because Apathy is buffer size limited, and we want to empty it out asap
libuv Transport added
LiteNetLib Transport added
Apathy updated to V1.13 (deterministic send/recv buffer behaviour. fixes the Linux bug)
NetworkTransformServerSystem uses Unreliable channel now
breaking: NetworkTransformClient/ServerSystem is not created automatically anymore. Make sure to have the authoring components attached to each scene’s NetworkClient/Server GameObject
breaking: TransformClient/ServerMessageSystem is not created automatically anymore. Make sure to have the authoring components attached to each scene’s NetworkClient/Server GameObject
breaking: Spawn/UnspawnMessageSystem is not created automatically anymore. Make sure to have the authoring components attached to each scene’s NetworkClient GameObject
feature: DependencyInjection now runs before OnCreate
fix: ClientConnectedSimulationSystemGroup: client null check for cases where there is no NetworkClientAuthoring component in the scene
fix: ServerActiveSimulationSystemGroup: client null check for cases where there is no NetworkClientAuthoring component in the scene
fix: TransformClientMessageSystem overwrites OnCreate/OnDestroy but didn't call ClientMessageSystem's base.OnCreate/OnDestroy, causing bugs if we actually use OnCreate/OnDestroy in ClientMessageSystem
fix: NetworkClient/ServerMessageSystem uses OnCreate to register messages. Fixes a bug where a message would come in before the handler was registered, because we are in ConnectedGroup/ActiveGroup, so it only registered after connected and after the message was already received.
Range slider is now only shown while server is running (and not on client anymore)
Extensions: NativeMultiHashMap.TryIterator for easier iterations
NetworkClientSystem.Send(NativeList) for Burst/Job support added
perf: NetworkTransformClientSystem uses Burst. For 75k Entities it reduces system time from 11ms to 0.33ms. So it's 30x faster.
breaking: NetworkServerSystem.Send parameters switched for consistency and ease of use
fix: TransportServer/ClientSystems are now updated in LateSimulationSystemGroup after all other systems. Fixes a bug where the Chat demo wouldn't work because Transport.OnStartRunning would set apathy's OnConnected/OnData hooks before Client.OnStartRunning would set the Transport hooks, causing them to be not set. Also avoids similar bugs in the future because update order is now deterministic.
Apathy updated to the latest version. Reduces memory usage per connection from around 2GB to 64KB and removes the 1-3s allocation freeze when clicking the client connect button.
Benchmark Example: fix MonsterMovementSystem seed is never zero anymore to avoid ArgumentException in Unity.Mathematics
Upgraded to Unity 2019.4 LTS
perf: NetworkTransformServerSystem Burst compiled. For 10k Entities with interval=0, it required 20-22ms without Burst and 5-6ms with Burst now.
perf: InterestManagement uses NativeMultiMaps to buffer Spawn/Unspawn messages instead of using DynamicBuffers. With 10k Entities at interval=0, it reduces system time from 8ms to 1ms.
Chat Example: added interest management to avoid DependencyInjection warning.
fix: NetworkTransform interpolation on clients is applied in main thread instead of Job. Movement is smooth again, especially noticeable in the Pong demo.
fix: Bootstrap.Initialize calls TypeManager.Initialize before using types. Fixes a bug where development builds on some platforms would throw a "The TypeManager must be initialized before the TypeManager can be used" Assertion failure.
perf: TransformClientMessageSystem batch processes all new TransformMessages with an Entities.ForEach call in each Update. This is a lot better than calling TryGetValue and SetComponentData 10k times.
perf: TransformClientMessageSystem runs in a Job. Applying TransformMessages on the client for 50k Entities reduced from originally 200ms for OnMessage SetComponentData to 0.05ms with Job/Burst.
NetworkServerSystem.Send NativeMultiHashMap function added for Jobs
Extensions: DynamicBuffer.Contains modified for Job support
InterestManagement restructured for Burst support. When rebuilding every frame with 10k Entities, the system time was reduced from 339ms per Update to 5.89ms per Update.
10k Example renamed to Benchmark with configurable spawn amount in the new SpawnSystemAuthoring component.
Benchmark Example: added Slider to modify visibility radius at runtime.
NetworkMessage serialization automated, and it’s faster now.
Increased test coverage internally
NetworkServer/Client message handlers use generic message delegates so that NetworkServer/ClientMessageSystem don’t need the OnMessageInternal workaround anymore.
perf: SegmentWriter.WriteBytes: use UnsafeUtility.MemCpy instead of Array.Copy because it's 25% faster
perf: Entities.ForEach queries read-only parameters are now marked as ‘in’ everywhere
Unity updated to 2019.3.14
Entities/Burst Packages updated to latest versions
fix: SegmentReader.Remaining calculation now works with ArraySegments that start at an offset
fix: ApathyTransportServer/ClientSystem now applies configuration in OnStartRunning instead of OnCreate so that Authoring settings are actually applied
performance: Apathy uncorked. Apathy performance is now on par with MemoryTransport. At least 20x faster than before. Try the 10k Demo with max visibility.
usability: NetworkServer/ClientMessageSystem: OnMessage parameter is the actual message type instead of NetworkMessage now
SegmentReader made 5x faster: 1mio x ReadFloat3 down from 2765ms to 538ms
SegmentWriter made 3x faster: 1mio x WriteFloat3 down from 922ms to 345ms
(Job)ComponentSystems converted to SystemBase
Pong/Chat/Physics demos added
Fixed clients not despawning other disconnected client’s players