Skip to content

fix: late time sync no longer steps client time back (back-port) - #4263

Open
NoelStephensUnity wants to merge 2 commits into
develop-2.0.0from
fix/time-no-backward-hard-reset-2.0.0
Open

NoelStephensUnity wants to merge 2 commits into
develop-2.0.0from
fix/time-no-backward-hard-reset-2.0.0

Conversation

@NoelStephensUnity

@NoelStephensUnity NoelStephensUnity commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

This is a back-port of #4262

Purpose of this PR

A late time sync no longer steps a client's network time back, and a NetworkTransform keeps sending state updates if the time does step back.

Fixes #4249.

What needed fixing: a time sync that arrives late (a resend under packet loss, or one read after a long frame) makes the server look further behind than it is. When the gap passed HardResetThresholdSec (0.2 s), NetworkTimeSystem.Advance hard-reset the client's time backwards. Owner authoritative NetworkTransforms skipped every tick at or below the last one sent, so they sent no state updates until the client's time caught up again.

What changes:

  • NetworkTimeSystem.Advance only hard-resets forward. When a sync puts the desired time more than HardResetThresholdSec behind, time slows down by AdjustmentRatio until it catches up. Reset() can still step time back.
  • NetworkTransform skips only a repeated tick. If the tick goes back, it keeps sending with ticks above the last one sent, so non-authority instances do not drop the states as old.

TimeSyncMessage stays reliable (all messages share one delivery so NetworkMessageManager keeps their order).

PR Scope:

  • NetworkTimeSystem hard reset direction.
  • NetworkTransform tick gate.

Jira ticket:

MTT-16795

Changelog

  • Fixed: Issue where a time sync that arrived late could step a client's network time back, so the NetworkTransforms it owns sent no state updates until its time caught up again. A late time sync now slows the client's time down instead, and a NetworkTransform keeps sending with increasing ticks if the time does step back.

Documentation

  • No documentation changes or additions were necessary.

Testing & QA (How your changes can be verified during release Playtest)

Functional Testing

Manual testing :

Automated tests:

  • Covered by existing automated tests
  • Covered by new automated tests

New tests: ClientNetworkTimeSystemTests (late sync slows time instead of stepping back, forward reset, Reset can step back) and NetworkTransformClockStepBackTests.OwnerKeepsSendingAfterClockStepsBack.

Does the change require QA team to:

  • Review automated tests?
  • Execute manual tests?
  • Provide feedback about the PR?

Up-port

#4262

Backports

N/A (this is the develop-2.0.0 backport)

NetworkTimeSystem.Advance only hard-resets forward. A sync that puts the
desired time more than HardResetThresholdSec behind now slews back at
AdjustmentRatio instead. Reset() can still step time back.

NetworkTransform's tick driver skips only a repeated tick; if the tick goes
back it keeps sending with ticks above the last one sent, so receivers do
not drop the states.
@NoelStephensUnity NoelStephensUnity changed the title fix: late time sync no longer steps client time back (2.0.0) fix: late time sync no longer steps client time back (back-port) Nov 30, 2026
@NoelStephensUnity
NoelStephensUnity marked this pull request as ready for review November 30, 2026 18:11
@NoelStephensUnity
NoelStephensUnity requested a review from a team as a code owner November 30, 2026 18:11

@u-pr u-pr Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Harness Review

Ship it

The change makes automatic time resets forward-only and preserves increasing transform ticks after a clock rewind. I examined the timing arithmetic, tick scheduling, receiver interpolation, and regression tests and found no actionable issues.

Reviewed commit be83536

🤖 Helpful? 👍/👎

@codecov-github-com

codecov-github-com Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

@@                Coverage Diff                @@
##           develop-2.0.0    #4263      +/-   ##
=================================================
+ Coverage          74.78%   74.79%   +0.01%     
=================================================
  Files                172      172              
  Lines              28400    28415      +15     
=================================================
+ Hits               21239    21254      +15     
  Misses              7161     7161              
Flag Coverage Δ
NGOv2_project_testproject_ubuntu 74.45% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...gameobjects/Runtime/Components/NetworkTransform.cs 89.33% <100.00%> (+0.01%) ⬆️
...de.gameobjects/Runtime/Timing/NetworkTimeSystem.cs 95.53% <100.00%> (+0.48%) ⬆️

... and 4 files with indirect coverage changes

Components Coverage Δ
com.unity.netcode.gameobjects 74.79% <100.00%> (+0.01%) ⬆️

ℹ️ Need help interpreting these results?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants