Skip to content

fix(playback): delay replay chunk sends until live chunks settle#81

Merged
DriftN2Forty merged 1 commit into
JustinDevB:devfrom
DriftN2Forty:fix/replay-chunk-send-gate
Jun 24, 2026
Merged

fix(playback): delay replay chunk sends until live chunks settle#81
DriftN2Forty merged 1 commit into
JustinDevB:devfrom
DriftN2Forty:fix/replay-chunk-send-gate

Conversation

@DriftN2Forty

Copy link
Copy Markdown
Collaborator

Summary

  • gate replay BRCP chunk sends on Paper reporting the matching live chunk as sent to the viewer
  • require one additional refresh after the first sent observation before sending the replay chunk snapshot
  • clear the readiness marker when chunks unload, restore, or leave the desired replay window
  • add regression coverage for the new send gate and stale chunk cancellation
  • document the behavior in the architecture notes and changelog

Why

When a replay viewer is teleported far away, replay chunks could be sent before the server finished streaming the real world chunks for that area. If the live chunk packets arrived afterward, they would overwrite the replay chunk overlay, which is especially visible on flat dedicated replay servers where the replay chunks appear to disappear.

This change makes replay chunk application wait until the viewer has already received the matching live server chunk and then waits one more refresh before sending the replay snapshot. That avoids relying on a fixed tick delay while still ensuring replay chunks land after the live chunk stream settles.

Testing

  • mvn -Dtest=ReplayBlockManagerTest test
  • mvn test

What changed:
- Added a replay chunk send gate in ReplayBlockManager.
- Production replay chunks now wait until viewer.isChunkSent(...) reports the matching real server chunk has been sent.
- Added a one-refresh grace after first observing the server chunk as sent before sending the replay chunk.
- Cleans up the readiness tracking when chunks leave view, restore, discard, or session cleanup runs.
- Added regression tests for:
- Waiting for isChunkSent + one refresh.
- Avoiding stale replay chunk sends after leaving view before the server chunk is ready.
- Updated CHANGELOG.md.
- Updated docs/ARCHITECTURE.md.
@DriftN2Forty DriftN2Forty merged commit d18f510 into JustinDevB:dev Jun 24, 2026
1 check passed
@DriftN2Forty DriftN2Forty deleted the fix/replay-chunk-send-gate branch June 24, 2026 01:47
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