Skip to content

fix(mapgen-studio): add rAF backstop timeout to prevent viz commits being starved in backgrounded documents#1623

Merged
mateicanavra merged 1 commit into
mainfrom
design/first-run-visibility
Jun 12, 2026
Merged

fix(mapgen-studio): add rAF backstop timeout to prevent viz commits being starved in backgrounded documents#1623
mateicanavra merged 1 commit into
mainfrom
design/first-run-visibility

Conversation

@mateicanavra

Copy link
Copy Markdown
Owner

After a first run from an empty stage, the canvas could remain stuck on the "Awaiting matter" state even after the run completed and the footer showed "Ready". The root cause is that vizStore batches all commits — including streamed manifest updates — exclusively onto requestAnimationFrame, and browsers throttle rAF indefinitely for hidden or backgrounded documents. This means viz events can sit uncommitted while non-rAF state like run status continues updating normally, producing a stale empty canvas.

The fix adds a 50ms setTimeout backstop alongside the existing rAF in requestCommit. Whichever fires first commits the pending state and cancels the other. Foreground behavior is unchanged since rAF wins the race in visible documents; Node/test behavior is also unchanged since the setTimeout fallback path already existed for environments without requestAnimationFrame.

Camera fit and default layer selection were investigated as alternative causes and confirmed already correctly implemented — no changes were needed there.

This was referenced Jun 12, 2026
@github-actions

Copy link
Copy Markdown

Railway preview (MapGen Studio): not provisioned for this PR.

Policy (Graphite stacks): previews are created only for the top-of-stack PR by default.

  • To force a preview for this PR: add label railway-preview
  • To suppress a preview: add label no-railway-preview

Debug: {"isClosed":false,"isFork":false,"suppress":false,"force":false,"isTopOfStack":false,"hasToken":true,"draft":false}

mateicanavra commented Jun 12, 2026

Copy link
Copy Markdown
Owner Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

mateicanavra commented Jun 12, 2026

Copy link
Copy Markdown
Owner Author

Merge activity

  • Jun 12, 8:50 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 12, 9:29 PM UTC: Graphite rebased this pull request as part of a merge.
  • Jun 12, 9:29 PM UTC: @mateicanavra merged this pull request with Graphite.

@mateicanavra
mateicanavra changed the base branch from design/explore-toolbar to graphite-base/1623 June 12, 2026 21:26
@mateicanavra
mateicanavra changed the base branch from graphite-base/1623 to main June 12, 2026 21:27
… commit backstop

OpenSpec mapgen-studio-first-run-visibility. Diagnosis recorded in design.md:
the invisible first run is NOT reproducible at tip from a clean slate — first-
manifest auto-fit and selection fallbacks verified present and exercised
(fresh-storage run renders framed matter, zero extra clicks). The one mechanism
consistent with the original one-off is vizStore's rAF-only commit batching,
which background tabs throttle indefinitely; requestCommit now pairs rAF with a
50ms timeout backstop (whichever fires first cancels the other). No camera or
selection behavior changes. tsc + 144 tests + strict validation green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mateicanavra
mateicanavra force-pushed the design/first-run-visibility branch from 77ea346 to 5ddae8f Compare June 12, 2026 21:28
@mateicanavra
mateicanavra merged commit 0013358 into main Jun 12, 2026
This was referenced Jun 12, 2026
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