Skip to content

fix(render): incremental redraw during replay playback - #151

Merged
mparrett merged 1 commit into
mainfrom
fix/replay-blanking
Jul 20, 2026
Merged

mparrett merged 1 commit into
mainfrom
fix/replay-blanking

Conversation

@mparrett

Copy link
Copy Markdown
Collaborator

What

play-replay now redraws incrementally during playback — a dirty FOV-delta render per turn — instead of full-repainting every frame. Full repaint stays only for a floor change, where the whole viewport turns over anyway.

Independent of the render-perf stack (#145/#146/#149): the change is in play-replay, not render.lg, and render-dirty is already the live path on main.

Why

render-full blanks the entire terminal before it repaints — it paints every row with the background colour, then draws the panels on top. The live game loop only pays that cost when it has to (floor change or resize); every normal turn goes through render-dirty, which touches only the cells that changed and never clears.

play-replay never adopted that split — it called render-full on every action. So each replayed turn cleared the screen and repainted it, and on the web build that blank-then-repaint reads as a full-screen flicker across the whole playback (#110).

How

Mirror play/play-advance: compare (:depth w') against the pre-action depth, render-dirty w' w when they match, render-full on a floor change. render-dirty takes the previous world as its diff base — the reduce already carries it, so threading it in is the whole change.

I left out the live loop's resize branch on purpose. Replay has no interactive resize mid-playback; a stray resize would leave one stale frame until the next turn redraws, which isn't worth polling term/size every frame for. Easy to add back if that turns out to matter.

Safety

Render-only. The seed chain and action log are untouched, so a replayed run stays bit-identical — same reconstruction, only fewer escapes drawing it. Verified in the browser: the replayed run animates cell-by-cell with the map, HUD, and log staying put frame to frame, no full-screen blank between turns. Existing suite passes.

Closes #110

play-replay repainted the whole screen every frame via render-full, which
first blanks the entire terminal with the bg colour (render.lg: "blank entire
terminal") and then redraws. On the web build that blank-then-repaint reads as
a visible full-screen flicker on each replayed turn (#110).

Mirror the live play loop (play/play-advance): render-dirty per turn — an
incremental FOV-delta redraw with no screen clear — and fall back to a full
repaint only on a floor change, where the whole viewport legitimately changes.

Render-only; the seed chain and action-log are untouched, so replay stays
bit-identical. Verified in the browser: the replayed run animates cell-by-cell
with no full-screen blank between frames.

Closes #110

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@mparrett mparrett added the deploy-preview Publish a gh-pages WASM preview for this PR label Jul 10, 2026
@github-actions

github-actions Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-20 23:04 UTC

@mparrett mparrett added the review-priority/low Minimal review effort left / already approved label Jul 10, 2026
@mparrett

mparrett commented Jul 10, 2026 •

Copy link
Copy Markdown
Collaborator Author

Confirmed fixed via this replay pr-151 AQAAAAAA...

To see the problem, try same against 149 (if still open):

Confirmed fixed via this replay pr-149 AQAAAAAA...

@mparrett

Copy link
Copy Markdown
Collaborator Author

Note on merge order. 151, then 150. (this PR fixes the flicker that will be more visible once 150 lands)

See: #150
cc: @nnunley

@mparrett
mparrett merged commit 7839ae6 into main Jul 20, 2026
8 checks passed
@mparrett
mparrett deleted the fix/replay-blanking branch July 23, 2026 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deploy-preview Publish a gh-pages WASM preview for this PR review-priority/low Minimal review effort left / already approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Web replay playback flickers (full-screen redraw each frame)

2 participants