Repository navigation
Commit ca1608f
feat: hybrid NetcodeConfig defaults (#4144)
* feat: auto-configure NetcodeConfig for hybrid mode
When Netcode for Entities is installed and a registered network prefab
carries a GhostObject, the project's NetCodeConfig is now aligned with
what NGO needs rather than leaving it to the user to discover.
The two settings hybrid mode cannot run without (single world hosting,
and automatic bootstrapping disabled since NetworkManager owns world
creation) are corrected whenever they drift. The Netcode for Entities
tick rates are driven from NetworkConfig.TickRate so that ghost
transform updates land on the same interval as everything else. The
snapshot, interpolation and transport values tuned against the 2000
instance stress test are applied once and then left alone, so a user's
own edits survive; Project Settings > Multiplayer > Netcode for
GameObjects can restore them.
The config is never created here. Netcode for Entities already creates
one unconditionally from its own InitializeOnLoadMethod, and creating a
second lands the project in its multiple-config error path.
Also:
- UnifiedIsConfiguredCorrectly now validates EnableClientServerBootstrap
and warns when the two tick rates diverge. Its two log messages were
missing their string interpolation prefixes.
- m_TempStreamSize returns to the Netcode for Entities default of 8192.
GhostSendSystem takes max(TempStreamInitialSize, dataStream.Capacity),
and capacity is DefaultSnapshotPacketSize, so 4192 had no effect.
- Unity.Netcode.Editor.Tests gains the UNIFIED_NETCODE version define.
Without it any hybrid editor test compiles away and reports zero cases
rather than failing.
- Adds a measurement fixture for sizing DefaultSnapshotPacketSize. It is
marked Explicit so its 24 cases stay out of the suites.
* style
Some comment clean up.
* fix and test
Fixing some things u-pr caught and adding a test to validate the update.
* refactor
Refactoring when the NetcodeConfig default settings are written.
Assuring that the NetcodeConfig tick rate is always the currently set tick rate when starting a session.
* test
Updating to use a more NGO like testing pattern.
Some comment clean up is included.
* update
resolving concern over the .EndVertical();
* style
removing white space.
* chore: n4e 7.0.0 spellings, review feedback and snapshot size
N4E 7.0.0 renamed NetCodeConfig to NetcodeConfig and moved its types into
Unity.Netcode. Use the 7.0.0 spelling, aliased for 6.7.0 the way the rest of
the unified code already is.
The editor test assembly still declared UNIFIED_NETCODE as a versionDefine
after #4158 made it project-level, so its unified block compiled while the
runtime's did not. It also referenced Unity.NetCode by name alongside the GUID
for the same assembly. Both removed, UNIFIED_NETCODE_7_0_0 added.
The snapshot packet size drops from 15000 to 4096. A snapshot is sent
unreliably, so losing any one of its fragments loses the whole snapshot: 4096
spans 3 datagrams at the 1400 byte MTU where 15000 spanned 11, and still caps
~840 ghosts at the measured 4.87 bytes each. The defaults version is bumped so
a project that already recorded the marker picks the new value up.
Review feedback:
- The experimental opt-in is gone. N4E ships as a normal 3.0.0 release.
- ResolveGlobalConfig's project scan is gone. N4E assigns NetcodeConfig.Global
from an InitializeOnLoadMethod and delayCall runs after those complete, so
there is nothing left for a scan to catch.
- The apply log uses the contextual logger at Developer level.
- UnifiedIsConfiguredCorrectly reports which setting is wrong rather than
discarding the reason it already computed.
* feat: hybrid NetcodeConfig values applied at session start
Netcode for GameObjects no longer writes anything into the NetcodeConfig asset. NetworkManager writes the
in-memory global config immediately before the world is created from it, and Netcode for Entities seeds its
world singletons from that.
Two values are driven, both measured rather than assumed:
- The tick rates. NGO's own send queues are flushed by a system in N4E's SimulationSystemGroup, so a
simulation rate below NetworkConfig.TickRate starves NGO's outbound traffic. N4E defaults to 60 and NGO
to 30.
- The snapshot packet size, behind the new NetworkConfig.AutoConfigureSnapshotSize. N4E's default of one
MTU round-robins above roughly 230 GhostObjects: at 512 instances it holds a 13.51Hz effective update
rate against a 30Hz tick, where 4096 holds 30.00Hz with no saturated snapshots. Below that count the cap
is never reached, so it costs nothing.
UnifiedBootstrap no longer delegates to base.Initialize. Entities selects the most derived ICustomBootstrap,
so this type is the only one it instantiates under UNIFIED_NETCODE and N4E's own Initialize is never reached
on its own. Calling it only gave N4E a chance to create worlds this bootstrap would then reject, which is why
EnableClientServerBootstrap had to be configured at all. It no longer does.
Removed with it: the editor applier, the Project Settings section, the applied-defaults version marker, and
the interpolation, despawn reservation and transport queue values. Those were tuned against a 2000 instance
stress test and are either inside N4E's own recommended ranges or inert below the snapshot cap.
The FailValidation and ClientDoesNotRequest hybrid test cases are removed pending a separate fix: the server
schedules its disconnect reason into N4E's outgoing RPC buffer and then tears the connection down in the same
call, before RpcSystem transmits it.
* test: move the connection approval latch fix out of this PR
The polled disconnect reason check belongs with the fix for the defect it found, not with the
NetcodeConfig changes. Only the removal of the FailValidation hybrid fixture stays here.
* chore: verbosity pass
Drops a stray blank line that was the only remaining change in NetcodeForGameObjectsProjectSettings, so
that file leaves the diff. Trims the comments that carried mechanism or measurements the PR description
already covers, keeping the reason each value or omission exists.
* chore: clarify the AutoConfigureSnapshotSize tooltip
---------
Co-authored-by: Unity Netcode CI <74025435+netcode-ci-service@users.noreply.github.com>1 parent 6fbe8b5 commit ca1608f
14 files changed
Lines changed: 267 additions & 10 deletions
File tree
- com.unity.netcode.gameobjects
- Editor
- Runtime
- Components/Helpers
- Configuration
- Core
- Tests
- Editor
- Runtime
- Connection
- TestHelpers
- testproject/Assets
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| |||
22 | 25 | | |
23 | 26 | | |
24 | 27 | | |
| 28 | + | |
| 29 | + | |
25 | 30 | | |
26 | 31 | | |
27 | 32 | | |
| |||
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
| |||
114 | 117 | | |
115 | 118 | | |
116 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
117 | 123 | | |
118 | 124 | | |
119 | 125 | | |
| |||
157 | 163 | | |
158 | 164 | | |
159 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
160 | 169 | | |
161 | 170 | | |
162 | 171 | | |
| |||
198 | 207 | | |
199 | 208 | | |
200 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
201 | 216 | | |
202 | 217 | | |
203 | 218 | | |
| |||
221 | 236 | | |
222 | 237 | | |
223 | 238 | | |
| 239 | + | |
224 | 240 | | |
225 | 241 | | |
226 | 242 | | |
| |||
Lines changed: 3 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
71 | 69 | | |
72 | 70 | | |
73 | 71 | | |
| |||
Lines changed: 80 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
55 | 69 | | |
56 | 70 | | |
57 | 71 | | |
| |||
Lines changed: 25 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1416 | 1416 | | |
1417 | 1417 | | |
1418 | 1418 | | |
1419 | | - | |
| 1419 | + | |
1420 | 1420 | | |
1421 | | - | |
| 1421 | + | |
1422 | 1422 | | |
1423 | 1423 | | |
1424 | 1424 | | |
1425 | 1425 | | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
1426 | 1446 | | |
1427 | 1447 | | |
1428 | 1448 | | |
| |||
1466 | 1486 | | |
1467 | 1487 | | |
1468 | 1488 | | |
| 1489 | + | |
1469 | 1490 | | |
1470 | 1491 | | |
1471 | 1492 | | |
| |||
1545 | 1566 | | |
1546 | 1567 | | |
1547 | 1568 | | |
| 1569 | + | |
1548 | 1570 | | |
1549 | 1571 | | |
1550 | 1572 | | |
| |||
1619 | 1641 | | |
1620 | 1642 | | |
1621 | 1643 | | |
| 1644 | + | |
1622 | 1645 | | |
1623 | 1646 | | |
1624 | 1647 | | |
| |||
Lines changed: 100 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
38 | 43 | | |
39 | 44 | | |
40 | 45 | | |
| |||
0 commit comments