Skip to content

Fix render speedup after simulation stalls/reconfiguration#54

Merged
Testtesttestestes merged 1 commit into
mainfrom
codex/fix-rendering-speed-during-simulation-lag
Mar 10, 2026
Merged

Fix render speedup after simulation stalls/reconfiguration#54
Testtesttestestes merged 1 commit into
mainfrom
codex/fix-rendering-speed-during-simulation-lag

Conversation

@Testtesttestestes

Copy link
Copy Markdown
Owner

Motivation

  • Visual animation could jump (appearing ~faster) after reinitialization or long stalls because the first frame used a stale timestamp when lastTime was set before async resource loading.
  • The animation loop could start/continue after the component effect was cleaned up, causing overlapping/ghost loops and inconsistent timing.
  • Kinematic history and reverse-impulse state were preserved across reinitialization, allowing stale motion state to influence the first rendered frames.

Description

  • Initialize lastTime to null and set it on the first animation frame to avoid computing a large dt from a stale timestamp (lastTimenull and first-frame assignment).
  • Add an isDisposed flag and early returns after async initialization and at the start of the loop to prevent starting or continuing the loop after effect cleanup (isDisposed guard).
  • Reset kinematicPrevRef and reverseImpulseRef when the simulation is reinitialized to avoid carrying over stale kinematic state.
  • Minor loop and lifecycle adjustments to ensure animation timing and cancellation are robust during reconfigure.

Testing

  • Ran npm run build and the production build completed successfully (Vite build finished without errors).

Codex Task

@Testtesttestestes Testtesttestestes merged commit 20b4951 into main Mar 10, 2026
1 check passed
@Testtesttestestes Testtesttestestes deleted the codex/fix-rendering-speed-during-simulation-lag branch March 10, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant