TimeSyncMessage is sent reliably, so a late one resets the client clock backwards and stalls its NetworkTransforms
维护者通常 3 天内回复
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 52/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
调研方向
Start by reading MessageDelivery.cs, NetworkTimeSystem, and NetworkTransform.cs around TickUpdate; the issue identifies these as the points where delivery, clock resets, and skipped transform ticks interact. Reproduce with the stated packet loss and delay, logging ServerTime.Tick and host-observed transform updates. Done means delayed syncs no longer cause backwards clock resets and owned transforms continue sending under the reproduction conditions.
由索引模型根据 Issue 内容生成。
描述
Description
TimeSyncMessage is sent reliably, although MessageDelivery says it's meant to stay unreliable. Under packet loss a time sync arrives late. The client takes its old host tick as current, its time offset passes HardResetThresholdSec (0.2 s by default), and NetworkTimeSystem hard-resets the client's clock backwards.
After that, NetworkTransformTickRegistration.TickUpdate skips while CurrentTick <= m_LastTick. Every NetworkTransform the client owns therefore sends nothing until its clock passes the last tick it sent. Teammates see that player freeze for up to about 0.5 s and then jump.
Details (line numbers from 2.13.3; the same code is in develop-3.x.x today):
MessageDelivery.cs: the summary ofk_SkipMessageTypessays "Skip the time sync messages since it has always used unreliable network delivery". But the set holds onlyNamedMessageandUnnamed. SoUpdateMessageTypesgivesTimeSyncMessageReliableFragmentedSequenced, andNetworkTimeSystemsends it withMessageDeliveryType<TimeSyncMessage>.DefaultDelivery.NetworkTimeSystem: a sync whose send tick is old by the time it arrives produces a desired offset more than 0.2 s from the current one, so the clock is hard-reset to it, back in time.NetworkTransform.cs:4765(NetworkTransformTickRegistration.TickUpdate):if (CurrentTick <= m_LastTick)with the comment// TODO FIX: The local NetworkTickSystem can invoke with the same network tick as before. After a backward reset, this skips every tick until the clock catches up.
Reproduce Steps
- Host + 1 client (client-server), with the simulated poor connection on the host: about 75 ms delay, ±20 ms jitter and 2% packet loss.
- On the client, log
NetworkManager.ServerTime.Tickevery frame for a few minutes. - Give the client an owner-authoritative
NetworkTransformthat moves continuously, and log on the host when its state updates arrive.
Actual Outcome
About twice a minute the client's ServerTime.Tick steps backwards (one example: 568 → 548). The client's NetworkTransform sends nothing until its tick passes 568 again, so the host sees it stand still for up to about 0.5 s and then jump.
Expected Outcome
A delayed time sync doesn't move a client's clock backwards, and its transforms keep sending. Possible fixes:
- send
TimeSyncMessageunreliably (add it tok_SkipMessageTypes, as the comment intends), so a lost one is replaced by the next a second later instead of arriving late; - or ignore a time sync older than the last one applied;
- and/or let
NetworkTransformTickRegistrationrecover from a backward tick (resetm_LastTick) instead of skipping until the clock catches up.
Screenshots
None. The numbers come from per-frame logs.
Environment
- OS: Windows 11 Pro
- Unity Version: 6000.3.27f1
- Netcode Version: 2.13.3 (also present in
develop-3.x.xand 3.2.0) - Netcode Commit: the v2.13.3 release
- Netcode Topology: Client-Server (host)
Additional Context
- Unity Transport 2.7.4.
- Our workaround: each client raises
NetworkTimeSystem.HardResetThresholdSecto 1 s when it starts. With that, the backward resets went from about two a minute to none in three minutes under the same conditions.
- 主要语言
- C#
- 星标
- 2.3k
- 派生
- 465
- 平均合并
- 3 天 12 小时
- 30 天内合并 PR
- 39
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Unity-Technologies/com.unity.netcode.gameobjects 的其他 Issue
-
NetworkTransform: half-float base update dropped as out of order when UseUnreliableDeltas is on, so later deltas decode ~2 m off可能已有人在做 @NoelStephensUnity 于 8 天前认领。 未关闭port:3.x-completed priority:medium stat:imported type:bug
难度 4/5 3-5 天 新手友好度 57/100
Unity-Technologies/com.unity.netcode.gameobjects#4248 ·
维护者通常 3 天内回复
-
Tracking type:feature-2.x
难度 5/5 一周以上 新手友好度 35/100
Unity-Technologies/com.unity.netcode.gameobjects#3870 · 5 条评论 ·
维护者通常 3 天内回复
-
Tracking type:feature
难度 4/5 3-5 天 新手友好度 48/100
Unity-Technologies/com.unity.netcode.gameobjects#3830 · 7 条评论 ·
维护者通常 3 天内回复
-
priority:medium stat:imported type:feature type:feature-2.x
难度 4/5 3-5 天 新手友好度 42/100
Unity-Technologies/com.unity.netcode.gameobjects#3706 · 5 条评论 ·
维护者通常 3 天内回复
-
Client NetworkObjects experience Awake, Start, OnEnable, and TriggerEnter, CollisionEnter at world 0,0,0 upon instantiation可能重新可做 @NoelStephensUnity 于 492 天前认领,目前没有进行中的 PR。 未关闭priority:medium stat:imported type:bug
Unity-Technologies/com.unity.netcode.gameobjects#3553 · 3 条评论 · 2 个 reaction · 已指派 1 人 ·
维护者通常 3 天内回复
查看 Unity-Technologies/com.unity.netcode.gameobjects 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
umbraco/Umbraco.Automate#612 ·
维护者通常 1 天内回复
-
崩溃日志只按 CRLF 分行未关闭
难度 2/5 1-3 小时 新手友好度 72/100
PCL-Community/PCL-CE#3872 ·
维护者通常 1 天内回复
-
type:task ux
难度 2/5 1-3 小时 新手友好度 72/100
elsa-workflows/elsa-foundation#5253 ·
维护者通常 1 天内回复