Skip to content

Commit 933c8cf

Browse files
author
Unity Technologies
committed
com.unity.netcode@1.0.15
## [1.0.15] - 2023-07-27 ### Changed * Updated com.unity.entities dependency to 1.0.14 * Use of non required TempJob allocation and use Allocator.Temp instead. ### Fixed * Runtime EntityQuery leaks and reduce runtime memory pressure due to continuously allocating queries without disposing. * Reduced memory usage in Editor tests, by avoiding allocating queries continuously in hot paths.
1 parent b414c7e commit 933c8cf

39 files changed

+516
-555
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
# Changelog
22

33

4+
## [1.0.15] - 2023-07-27
5+
6+
### Changed
7+
8+
* Updated com.unity.entities dependency to 1.0.14
9+
* Use of non required TempJob allocation and use Allocator.Temp instead.
10+
11+
### Fixed
12+
13+
* Runtime EntityQuery leaks and reduce runtime memory pressure due to continuously allocating queries without disposing.
14+
* Reduced memory usage in Editor tests, by avoiding allocating queries continuously in hot paths.
15+
16+
417
## [1.0.12] - 2023-06-19
518

619
### Changed
@@ -37,6 +50,8 @@
3750

3851
* exceptions when NetworkRequestListen and/or. NetworkRequestConnect are handled and proper handling of multiple (erroneous) requests presents.
3952
* A problem with InterpolatedTick, going back and not recovering correctly in presence of large application, either the server or the client, stalls (i.e after loading).
53+
* `MultiplayerPlayModeWindow > Dump Packet Logs` now works more reliably, now works with NUnit tests, and dump files are named with more context.
54+
* Fixed bug in `GhostSendSystem` that caused it to not replicate ghosts when enabling packet dumps. `GhostValuesAreSerialized_WithPacketDumpsEnabled` test added.
4055

4156

4257
## [1.0.8] - 2023-04-17

Editor/MultiplayerPlayModeWindow.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -973,9 +973,8 @@ static void DisconnectSpecificClient(EntityManager entityManager, NetworkId netw
973973
{
974974
entityManager.CompleteAllTrackedJobs();
975975
using var activeConnectionsQuery = entityManager.CreateEntityQuery(ComponentType.ReadOnly<NetworkId>(), ComponentType.Exclude<NetworkStreamRequestDisconnect>());
976-
977-
using var entities = activeConnectionsQuery.ToEntityArray(Allocator.Temp);
978-
using var networkIds = activeConnectionsQuery.ToComponentDataArray<NetworkId>(Allocator.Temp);
976+
var entities = activeConnectionsQuery.ToEntityArray(Allocator.Temp);
977+
var networkIds = activeConnectionsQuery.ToComponentDataArray<NetworkId>(Allocator.Temp);
979978
for (var i = 0; i < entities.Length; i++)
980979
{
981980
if (networkIds[i].Value == networkId.Value)
@@ -990,8 +989,7 @@ static void DisconnectAllClients(EntityManager entityManager, NetworkStreamDisco
990989
{
991990
entityManager.CompleteAllTrackedJobs();
992991
using var activeConnectionsQuery = entityManager.CreateEntityQuery(ComponentType.ReadOnly<NetworkId>(), ComponentType.Exclude<NetworkStreamRequestDisconnect>());
993-
994-
using var entities = activeConnectionsQuery.ToEntityArray(Allocator.Temp);
992+
var entities = activeConnectionsQuery.ToEntityArray(Allocator.Temp);
995993
for (var i = 0; i < entities.Length; i++)
996994
{
997995
// TODO - Convert to batch when API supports 1 NetworkStreamRequestDisconnect for n entities.

Runtime/Analytics/NetCodeAnalyticsState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public static int GetPlayerCount()
2121

2222
public static uint GetUpdateLength(World world)
2323
{
24-
var query = world.EntityManager.CreateEntityQuery(ComponentType.ReadOnly<GhostSendSystemAnalyticsData>());
24+
using var query = world.EntityManager.CreateEntityQuery(ComponentType.ReadOnly<GhostSendSystemAnalyticsData>());
2525
if (query.CalculateEntityCount() != 1)
2626
{
2727
return 0;

Runtime/Authoring/Hybrid/GhostAuthoringComponentBaker.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,8 @@ partial class GhostAuthoringBakingSystem : SystemBase
199199

200200
protected override void OnCreate()
201201
{
202-
base.OnCreate();
203-
204202
// Query to get all the root entities baked before
205-
m_NoLongerBakedRootEntities = EntityManager.CreateEntityQuery(new EntityQueryDesc
203+
m_NoLongerBakedRootEntities = GetEntityQuery(new EntityQueryDesc
206204
{
207205
None = new []
208206
{
@@ -218,7 +216,7 @@ protected override void OnCreate()
218216
m_NoLongerBakedRootEntitiesMask = m_NoLongerBakedRootEntities.GetEntityQueryMask();
219217

220218
// Query to get all the root entities baked before
221-
m_GhostEntities = EntityManager.CreateEntityQuery(new EntityQueryDesc
219+
m_GhostEntities = GetEntityQuery(new EntityQueryDesc
222220
{
223221
All = new []
224222
{

Runtime/ClientServerWorld/ClientServerBootstrap.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ public void OnCreate(ref SystemState state)
560560
var world = World.All[i];
561561
if (world.IsClient())
562562
{
563-
var driver = world.EntityManager.CreateEntityQuery(ComponentType.ReadOnly<NetworkStreamDriver>());
563+
using var driver = world.EntityManager.CreateEntityQuery(ComponentType.ReadOnly<NetworkStreamDriver>());
564564
UnityEngine.Assertions.Assert.IsFalse(driver.IsEmpty);
565565
var driverData = driver.ToComponentDataArray<NetworkStreamDriver>(Allocator.Temp);
566566
UnityEngine.Assertions.Assert.IsTrue(driverData.Length == 1);

Runtime/Connection/DriverMigrationSystem.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,12 @@ public int StoreWorld(World sourceWorld)
102102

103103
driverMap.Add(ticket, default);
104104

105-
var driverSingletonQuery = sourceWorld.EntityManager.CreateEntityQuery(ComponentType.ReadWrite<NetworkStreamDriver>());
105+
using var driverSingletonQuery = sourceWorld.EntityManager.CreateEntityQuery(ComponentType.ReadWrite<NetworkStreamDriver>());
106106
ref var driverSingleton = ref driverSingletonQuery.GetSingletonRW<NetworkStreamDriver>().ValueRW;
107107
driverSingletonQuery.CompleteDependency();
108-
driverSingletonQuery.Dispose();
109108
Store(driverSingleton.StoreMigrationState(), ticket);
110109

111-
var filter = sourceWorld.EntityManager.CreateEntityQuery(typeof(NetworkStreamConnection));
110+
using var filter = sourceWorld.EntityManager.CreateEntityQuery(typeof(NetworkStreamConnection));
112111
var backupWorld = new World(sourceWorld.Name, sourceWorld.Flags);
113112

114113
backupWorld.EntityManager.MoveEntitiesFrom(sourceWorld.EntityManager, filter);

Runtime/Connection/NetworkStreamDriver.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ public Entity Connect(EntityManager entityManager, NetworkEndpoint endpoint, Ent
166166
if (DriverStore.DriversCount != 1)
167167
throw new InvalidOperationException("Too many NetworkDriver created for the client. Only one NetworkDriver instance should exist");
168168
var builder = new EntityQueryBuilder(Allocator.Temp).WithAll<NetworkSnapshotAck>();
169-
if (!entityManager.CreateEntityQuery(builder).IsEmpty)
169+
using var query = entityManager.CreateEntityQuery(builder);
170+
if (!query.IsEmpty)
170171
throw new InvalidOperationException("Connection to server already initiated, only one connection allowed at a time.");
171172
#endif
172173
#if UNITY_EDITOR || !UNITY_CLIENT

Runtime/Debug/NetCodeDebugConfig.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ internal partial struct DebugConnections : ISystem
4242
[BurstCompile]
4343
public void OnCreate(ref SystemState state)
4444
{
45-
m_ConnectionsQueryWithout = state.EntityManager.CreateEntityQuery(new EntityQueryBuilder(Allocator.Temp).WithAll<NetworkStreamConnection>().WithNone<EnablePacketLogging>());
46-
m_ConnectionsQueryWith = state.EntityManager.CreateEntityQuery(new EntityQueryBuilder(Allocator.Temp).WithAll<NetworkStreamConnection>().WithAll<EnablePacketLogging>());
45+
m_ConnectionsQueryWithout = state.GetEntityQuery(new EntityQueryBuilder(Allocator.Temp).WithAll<NetworkStreamConnection>().WithNone<EnablePacketLogging>());
46+
m_ConnectionsQueryWith = state.GetEntityQuery(new EntityQueryBuilder(Allocator.Temp).WithAll<NetworkStreamConnection>().WithAll<EnablePacketLogging>());
4747
}
4848

4949
public void OnUpdate(ref SystemState state)
@@ -78,13 +78,6 @@ public void OnUpdate(ref SystemState state)
7878
state.EntityManager.RemoveComponent<EnablePacketLogging>(m_ConnectionsQueryWith);
7979
}
8080
}
81-
82-
[BurstCompile]
83-
public void OnDestroy(ref SystemState state)
84-
{
85-
m_ConnectionsQueryWithout.Dispose();
86-
m_ConnectionsQueryWith.Dispose();
87-
}
8881
}
8982
#endif
9083
}

Runtime/Rpc/RpcCommandRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public partial class RpcCommandRequestSystemGroup : ComponentSystemGroup
8989
protected override void OnCreate()
9090
{
9191
base.OnCreate();
92-
m_Query = EntityManager.CreateEntityQuery(ComponentType.ReadOnly<SendRpcCommandRequest>());
92+
m_Query = GetEntityQuery(ComponentType.ReadOnly<SendRpcCommandRequest>());
9393
}
9494
protected override void OnUpdate()
9595
{

Runtime/Snapshot/GhostCollectionSystem.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,13 @@ public void OnCreate(ref SystemState state)
182182

183183
entityQueryBuilder.Reset();
184184
entityQueryBuilder.WithAll<NetworkStreamInGame>();
185-
m_InGameQuery = state.EntityManager.CreateEntityQuery(entityQueryBuilder);
185+
m_InGameQuery = state.GetEntityQuery(entityQueryBuilder);
186186
entityQueryBuilder.Reset();
187187
entityQueryBuilder.WithAll<NetworkId>();
188-
m_AllConnectionsQuery = state.EntityManager.CreateEntityQuery(entityQueryBuilder);
188+
m_AllConnectionsQuery = state.GetEntityQuery(entityQueryBuilder);
189189
entityQueryBuilder.Reset();
190190
entityQueryBuilder.WithAll<Prefab, GhostType>().WithNone<GhostPrefabRuntimeStrip>();
191-
m_RegisterGhostTypesQuery = state.EntityManager.CreateEntityQuery(entityQueryBuilder);
191+
m_RegisterGhostTypesQuery = state.GetEntityQuery(entityQueryBuilder);
192192

193193
if (!SystemAPI.TryGetSingletonEntity<CodeGhostPrefab>(out m_CodePrefabSingleton))
194194
m_CodePrefabSingleton = state.EntityManager.CreateSingletonBuffer<CodeGhostPrefab>();
@@ -207,8 +207,6 @@ public void OnDestroy(ref SystemState state)
207207
m_AllComponentTypes.Dispose();
208208
if (m_StableHashToComponentTypeIndex.IsCreated)
209209
m_StableHashToComponentTypeIndex.Dispose();
210-
m_InGameQuery.Dispose();
211-
m_AllConnectionsQuery.Dispose();
212210
state.EntityManager.DestroyEntity(m_CollectionSingleton);
213211
#if UNITY_EDITOR || NETCODE_DEBUG
214212
m_PredictionErrorNames.Dispose();

0 commit comments

Comments
 (0)