Skip to content

fix: render streamed Studio terrain incrementally#340

Merged
RSamaium merged 1 commit into
v5from
agent/fix-studio-terrain-streaming-339
Jul 24, 2026
Merged

fix: render streamed Studio terrain incrementally#340
RSamaium merged 1 commit into
v5from
agent/fix-studio-terrain-streaming-339

Conversation

@RSamaium

Copy link
Copy Markdown
Owner

What changed

  • consolidate all Studio stream deltas from one packet before rebuilding client map state
  • publish dirty and active terrain regions with a monotonic stream generation
  • invalidate only intersecting 768 px terrain renderer chunks
  • preserve unaffected canvases, Pixi textures, sprites, and water overlays
  • keep the existing full-map path for non-streamed Studio maps
  • add a patch changeset for @rpgjs/studio

Why

Each streamed chunk update changed the global terrain version. StudioTerrainChunkRenderer.renderMap() consequently recreated every terrain chunk synchronously, including terrain-control masks, morphology, and water overlays. A single movement-triggered stream update could block the browser main thread for hundreds of milliseconds.

The renderer now maps consolidated dirty regions to its own chunk grid and only rebuilds those entries. Removed regions destroy only renderer chunks no longer covered by retained stream data.

Closes #339.

Validation

  • pnpm vitest run packages/studio — 27 files, 190 tests passed
  • pnpm test --run — 152 files, 1,113 tests passed, 19 skipped
  • pnpm test:types — 3 files, 20 tests passed, no type errors
  • pnpm build and pnpm --filter @rpgjs/studio build
  • pnpm api:boundary
  • pnpm changeset status
  • packed @rpgjs/studio, installed it into the v5 starter, and completed a production build
  • started the starter on 127.0.0.1:4179, verified rendering and keyboard movement in Chromium, with no page errors or failed requests

Headless Chromium emitted only software-WebGL/GPU readback warnings; the rendered game and interaction were correct.

@RSamaium
RSamaium marked this pull request as ready for review July 24, 2026 08:48
@RSamaium
RSamaium merged commit 9fab626 into v5 Jul 24, 2026
6 checks passed
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.

Studio terrain streaming re-renders every terrain chunk on each streamed chunk update

1 participant