Skip to main content
Features

Snapshot traffic

Snapshots are compressed and sent in chunks over reliable RPCs.

Delta snapshots​

Each snapshot gets a sequence number. A client that has the previous one only gets a delta: the records (an actor, a player, the globals) that changed, plus removals. New clients get a full snapshot. An unchanged world sends nothing.

Every delta carries a hash of the complete state. If a client's rebuilt snapshot does not match, or a delta does not follow the snapshot it has, the client asks the host for a full snapshot. This happens by itself.

The host remembers the last 8 states. A client that fell a few sequences behind (a slow connection, a large transfer) gets a delta from the state it holds instead of a new full snapshot.

Measured with 4 players, 300 static props and gameplay going on:

Size
Full snapshot27 KB
Deltaabout 0.9 KB
Host traffic with deltasabout 4 KB/s
Host traffic without deltasabout 40 KB/s

Tuning​

  • Snapshot Interval: lower means less progress lost on a crash, but more traffic.
  • Use Delta Snapshots: turn off to always send full snapshots.
  • Chunk Size: compressed bytes per RPC.
  • Max Snapshot Bytes Per Second Per Client: caps the snapshot traffic to each client. 0 (the default) means no limit, with one chunk per frame. A low cap can delay a graceful handover or leave clients with an older snapshot. See Graceful handover timing.
  • Get Snapshot Stats (host) returns the size of the last full snapshot, last delta size, changed records, bytes per second and counts of fulls, deltas and resyncs. A summary is logged every 30 s.
  • Only mark what must survive as SaveGame. Large records that change often (big inventories) are resent whole every time they change.

Print Snapshot Stats: on the host, Get Snapshot Stats is broken into its fields and printed with Format Text

Size limit​

A full snapshot larger than Max Snapshot Bytes (compressed, default 512 KB) is not sent.

  • An existing client can still get a delta when deltas are enabled, the client's baseline is in the host's history, and the delta fits within the transfer limits.
  • New clients and clients that need a full resync cannot get a current snapshot while the full snapshot is over the limit. A new client without any snapshot cannot take part in a migration.
  • The host checks this limit when it builds a full payload. On the first over-limit result it logs an error and fires On Snapshot Too Large (Snapshot Bytes, Max Snapshot Bytes). A later full payload under the limit clears the flag. Get Snapshot Stats reports it as Over Size Limit, and the debug overlay shows it in red.

Clients ignore anything above twice Max Snapshot Bytes compressed (or 32 times that uncompressed), and the host does not send deltas that large.

Clients apply deltas in place and only hash the records that changed, so a small delta stays cheap on a large snapshot.

Testing resyncs​

HostMigration.Debug.DropEveryNthDelta N on a client drops every Nth delta, to see the resync at work.