Revised proposal for review — October 22, 2026
First measure peer connectivity, then build a minimal three-human, player-hosted experiment using reliable ordered WebRTC data channels. Rotate the host and judge the experience of each non-host player. Build private-room infrastructure and experiment with unreliable delivery only after those results justify the work. Keep the public arena server-authoritative and unchanged while measuring whether peer hosting improves responsiveness and reduces infrastructure use. This is a proposal, not an approved implementation or deployment. It does not replace the existing public hosting plan.
Priority order: stable simulation and rendering; responsive and fair play; reliable connections; reduced server cost. Less server traffic alone is not sufficient reason to ship a worse playing experience.
A shorter route may reduce the discrepancy between the turn a player sees locally and the turn the authority accepts. It does not eliminate that discrepancy or establish fairness by itself.
The October 22 code review found:
shared/multiplayer/room.js already separates the simulation authority from its transport. Inputs apply on the next authority tick after receipt; timestamps validate freshness and do not backdate collisions.shared/multiplayer/config.js specifies 120 Hz simulation and snapshots every four ticks (nominally 30 Hz). shared/multiplayer/hub.js pumps at approximately 60 Hz and batches catch-up steps, so a 120 Hz timestep does not promise input service within 8.3 ms.Keep collision rules, input application timing, prediction, and remote playback unchanged in the first experiment. Do not introduce rollback, a new fairness policy, deterministic lockstep, or a new AI policy while evaluating peer hosting.
Use two peers only for connectivity and protocol smoke checks. The first meaningful gameplay comparison needs three humans plus the normal AI workload, rotating each human through the host role. A two-human test always includes the advantaged host and can overstate the benefit.
In a star, Bob's turn reaches Carol through Bob → host authority → Carol; nearby non-hosts do not automatically get a direct gameplay path. Measure both legs and each participant's result, including a distant host and a host with weak upload. Later scale to six and twelve humans. Exclude public matchmaking, rankings, and large spectator audiences from the initial scope.
Reuse the existing authoritative JavaScript simulation and input rules behind a transport adapter. Inspect the current room implementation before extracting interfaces; avoid duplicating a second physics or AI implementation.
Run host simulation in a dedicated Web Worker so rendering and shader compilation do not directly block its execution. A worker is not an independent machine: CPU contention, battery management, browser suspension, and host network quality still matter. Creating the connection on the main thread is acceptable, but main-thread message handling still gives the path network → main thread → worker → main thread → network. Rendering stalls can delay remote inputs even when the worker keeps stepping. Feature-test transferable RTCDataChannel support in each target browser; where supported, compare channel handling in the dedicated worker against the main-thread bridge. Do not assume specification support establishes browser support. Measure receipt, worker dispatch, application, publication, and render delays separately.
The host's own player must submit inputs through the same validation and sequencing rules. Its network delay is still lower; this proposal does not promise to eliminate host advantage. Do not silently add artificial input delay to hide it.
Select the host explicitly and rotate it for every comparison; identify the role in the test UI. If the experiment succeeds, design host selection around the worst-served participant as well as CPU and upload capacity, rather than lowest average RTT alone. Peer hosts are trusted for casual private play; they cannot provide server-grade cheat resistance.
For the first game prototype, use reliable ordered delivery for the existing input and snapshot protocol. Keep input ordering and the dependent snapshot stream intact. Acknowledge command outcomes for diagnostics, distinguishing applied, rejected, and superseded control state from mere receipt; do not silently reinterpret existing gameplay rules.
After the gameplay gate passes, evaluate the following as separate changes:
| Information | First prototype | Later experiment |
|---|---|---|
| Motion snapshots | Existing ordered baseline-dependent stream | Independently decodable unreliable updates or acknowledged baselines |
| Turns | Reliable ordered commands | Redundant unordered commands only after an explicit gap/deadline design |
| Turbo/brake | Reliable ordered control state | Repeated current state with sequence protection and release recovery |
| Lifecycle, trails, deaths | Reliable ordered state/events | Reliable sequenced events coordinated with motion revisions |
| Initial state and repair | Reliable bounded transfer | Chunked repair with baseline/event IDs and checksums |
Before enabling unreliable snapshots, implement loss recovery. Do not drop a dependent snapshot and then send a delta based on it. Motion packets must identify the trail/event revision they require; define whether to buffer, defer display, or request repair when that revision is missing. Cross-channel arrival order must not corrupt collision geometry or presentation.
Unordered inputs need a separately reviewed policy for missing sequences: how long to wait, when to reject, and what the client does after rejection. Use consecutive resolved acknowledgments or selective acknowledgments, deduplicate retransmissions, and prevent later commands from silently invalidating earlier turns. Do not replay an old turn arbitrarily after a newer one. A missing release must not leave turbo or brakes engaged.
Use host simulation ticks as the authoritative time reference. Record clock-offset uncertainty and RTT asymmetry limitations; half of RTT is an estimate, not a measurement of one-way latency. Preserve current bounded timestamp validation. Client timestamps do not authorize arbitrary history rewrites.
Bound message sizes, queue depth, and bufferedAmount. With the original dependent stream, handle overload by explicit resynchronization or termination rather than dropping arbitrary deltas. Later independent motion updates may be coalesced before sending. Chunk repairs and bound their bandwidth. WebRTC data channels use SCTP, and channels within one association share congestion control; unordered delivery is not an unconstrained raw UDP socket or isolation from bulk traffic.
Mobile backgrounding, sleep, network changes, a closed host tab, and suspended workers must be tested. No user should remain indefinitely on a loading screen.
Use authenticated room admission, expiring invitation/rejoin tokens, short-lived TURN credentials, connection limits, and rate limits. Do not embed long-lived TURN secrets in the client. Validate every message's size, schema, round, sequence, and assigned player identity.
Direct peer connections can reveal participants' public IP addresses to peers. Explain this for private rooms; a relay-only option can reduce that exposure at the cost of relay bandwidth and an extra network hop. Avoid logging raw connection addresses unnecessarily.
Measure signaling requests and TURN bytes separately from simulation savings. TURN requires bandwidth capacity, abuse protection, monitoring, and region selection. A paid service or new deployment requires separate authorization.
| Option | Strength | Main limitation |
|---|---|---|
| Existing authoritative server | Stable ownership, public queue, independent authority | Current transport and server route remain |
| Better-region server with existing transport | Isolates hosting improvements with minimal client changes | Still server bandwidth and compute |
| Private WebRTC player host | Potential direct path and less hosted simulation | Host advantage, host device/load, disconnects |
| Dedicated server terminating WebRTC | Datagram-style delivery with independent authority | Requires a compatible backend and operational work |
| Existing proposed WebTransport server path | Another server-authoritative datagram option | Deployment and browser/network fallback requirements |
WebRTC is a transport choice, while peer hosting is an authority choice. Evaluate them separately. Do not assume the current Worker or room host can terminate WebRTC without a new backend component.
| Criterion | Measurement and gate |
|---|---|
| Precise turns — primary | Per-player p50/p95/p99 distance between local predicted and authoritative turn positions, divided by authored cycle length; also record predicted-survival/authoritative-death disagreements. Establish an absolute allowable error for each speed regime. |
| Non-host responsiveness | Per non-host input-to-authoritative-confirmation tails and remote input-to-visible-turn latency; require meaningful repeatable improvement over the server on intended networks. Never hide the slowest guest in an average with the host. |
| Correctness | Zero unexplained lost/duplicate turns, persistent state divergence, or incorrect round/trail recovery in the defined test suite. Every command must have a traceable outcome. |
| Scheduling and rendering | Set absolute limits for authority dispatch/tick stalls and client frame stalls at the chosen display target. Track accumulated/discarded time and catch-up bursts, not only average tick duration. |
| Connectivity | Set required join success rate and maximum join time across the declared browser/network matrix; report direct and relayed cases separately. |
| Capacity | Set supported player count, host upload/CPU budget, and maximum tolerated queue growth from measured workloads. |
When the authority rejects a turn or the cycle dies first, record that outcome rather than excluding it from turn-position statistics. Capture distance before collision and the rejection reason where available. Measure local response separately from confirmation; fast prediction alone is not evidence of authoritative improvement.
Seamless host migration, public peer matchmaking, persistent competitive rankings, full-mesh simulation, deterministic lockstep, rollback, and large spectator services are outside this experiment. Private-room polish and reconnect continuity are deferred until demonstrated gameplay benefit. Updating this document does not approve implementation.
These references support the transport capabilities. The topology, staging, thresholds, and acceptance criteria above are project proposals, not measured results.