Skip to content

fix: state sync for subjects spawned in the past#620

Open
aromancev wants to merge 1 commit into
foxssake:mainfrom
aromancev:fix/past-spawn
Open

fix: state sync for subjects spawned in the past#620
aromancev wants to merge 1 commit into
foxssake:mainfrom
aromancev:fix/past-spawn

Conversation

@aromancev

@aromancev aromancev commented Jun 23, 2026

Copy link
Copy Markdown

Currently, a node spawned in the past does not simulate correctly which leads to desync between different clients.

Failure mode

  1. Client fires a projectile at tick T.
  2. Server receives client input for tick T while the current tick is T + 1. Fires the projectile at tick T + 1.
  3. The projectile on the server is alive a tick later than on the client and it simulates incorrectly (it should've been already moving for one tick).

This failure has two components:

  1. It's ok to spawn the projectile later, but we need to set the correct spawn tick for the liveness check + run resim from that tick.
  2. If we only do [1], the simulation will corrupt the initial subject state. Network history will not revert it because it doesn't exist for ticks before subject was registered. This will lead to the projectile "skipping ahead" on some clients and hitting earlier than it's supposed to.

This change effectively does two things:

  • Ensures the spawned node is alive and resimulated from the correct tick.
  • Seeds network history for the spawn tick with unmodified values to prevent state corruption.

Note: spawn_tick is exposed on both synchronizers to control the exact spawn tick. It defaults to NetworkRollback.tick so simply spawning the node during the rollback simulation will work correctly. But if the consumer doesn't want to spawn the node during rollback, they can set spawn_tick to whatever tick they consider as the first alive tick when spawning the node (before the deferred process_settings executes).

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.

1 participant