Skip to content

FE-1500: fix StrictMode playback disposal - #9397

Open
kube wants to merge 1 commit into
mainfrom
codex/fe-1500-vite-playback
Open

FE-1500: fix StrictMode playback disposal#9397
kube wants to merge 1 commit into
mainfrom
codex/fe-1500-vite-playback

Conversation

@kube

@kube kube commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

🌟 What is the purpose of this PR?

Simulation playback stalled in development builds: PlaybackProvider disposed its playback state machine in a useEffect cleanup, and React Strict Mode's setup, cleanup, setup replay left the handle permanently disposed, so play() and rAF ticks became no-ops while frames kept arriving. This removes the disposal effect.

🔗 Related links

🔍 What does this change?

  • Removes the dispose-on-cleanup effect from PlaybackProvider. Playback owns only in-memory state; its rAF loop and store subscriptions are cleaned up by their own effects. A comment at the site records why no disposal happens there.
  • Adds a Strict Mode regression test that initializes a simulation, delivers frames across a rerender, drives two mocked animation frames, and asserts the frame index advanced.

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • does not modify any publishable blocks or libraries, or modifications do not need publishing

📜 Does this require a change to the docs?

The changes in this PR:

  • are internal and do not require a docs change

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

🛡 What tests cover this?

  • New: the react/playback/provider.test.tsx case "advances arriving frames when StrictMode replays mount effects".
  • Existing: the rest of the PlaybackProvider suite.

❓ How to test this?

  1. Checkout the branch and run yarn workspace @apps/petrinaut-website dev (the site mounts under StrictMode).
  2. Open the local demo, switch to Simulate, and press Play.
  3. Confirm the frame counter and playhead advance.

@vercel

vercel Bot commented Aug 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview Aug 29, 2026 2:04am
petrinaut Ready Ready Preview Aug 29, 2026 2:04am
petrinaut-docs Ready Ready Preview Aug 29, 2026 2:04am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hashdotdesign-tokens Ignored Ignored Preview Aug 29, 2026 2:04am

Request Review

@cursor

cursor Bot commented Aug 28, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Narrow React lifecycle fix with targeted test coverage; rAF cancellation remains in the existing playing effect.

Overview
Fixes simulation playback stalling in development when the app runs under React StrictMode. PlaybackProvider no longer calls playback.dispose() from a mount effect’s cleanup; that cleanup ran during StrictMode’s setup → cleanup → setup replay and left the same useState-held playback instance permanently disposed, so play() and rAF ticks stopped advancing the frame index while frames could still arrive.

A short comment documents that rAF and store subscriptions are torn down by their own effects, so the provider should not dispose the core playback handle on unmount replay. A new regression test wraps the provider in StrictMode, plays, rerenders with arriving frames, drives mocked animation frames, and expects currentFrameIndex to reach 2.

Reviewed by Cursor Bugbot for commit 5f3fdbb. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added area/infra Relates to version control, CI, CD or IaC (area) area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team labels Aug 28, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0171fa1. Configure here.

Comment thread libs/@hashintel/petrinaut/src/ui/viewer/viewer-quick-simulation-controls.tsx Outdated
@kube
kube changed the base branch from codex/fe-1500-oembed to main August 29, 2026 00:17
@github-actions github-actions Bot added area/deps Relates to third-party dependencies (area) area/apps area/apps > hash.design Affects the `hash.design` design site (app) labels Aug 29, 2026
@kube
kube force-pushed the codex/fe-1500-vite-playback branch from 0171fa1 to 0c6001f Compare August 29, 2026 00:17
@github-actions github-actions Bot removed area/deps Relates to third-party dependencies (area) area/apps area/apps > hash.design Affects the `hash.design` design site (app) labels Aug 29, 2026
@kube kube changed the title FE-1500: fix Vite playback and add viewer timeline FE-1500: fix StrictMode playback disposal Aug 29, 2026
@kube
kube requested a review from CiaranMn August 29, 2026 01:52
@kube
kube enabled auto-merge August 29, 2026 01:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/libs Relates to first-party libraries/crates/packages (area) type/eng > frontend Owned by the @frontend team

Development

Successfully merging this pull request may close these issues.

1 participant