Skip to content

Fix collision preview showing phantom collisions on low-density tables#13

Open
TimBeyer wants to merge 1 commit intomasterfrom
claude/fix-collision-preview-bug-5aXeW
Open

Fix collision preview showing phantom collisions on low-density tables#13
TimBeyer wants to merge 1 commit intomasterfrom
claude/fix-collision-preview-bug-5aXeW

Conversation

@TimBeyer
Copy link
Owner

Summary

  • simulate() always pushes a StateUpdate at time: 0 as the first replay entry. The first worker call correctly strips it via shift(), but subsequent calls included it in the data array sent to the main thread.
  • This StateUpdate contains snapshots of every circle, causing the collision preview renderer to match all balls and show them at stale positions — appearing as desynchronized collision indicators that vanish before the actual collisions occur.
  • On low-density tables (few balls, sparse events), the StateUpdate easily falls within the preview's lookahead window and persists across multiple frames, making the desync clearly visible.

Test plan

  • npm test — all 42 tests pass
  • npm run build — clean production build
  • Manual: npm run dev with 3-5 balls + collision preview enabled; phantom collision indicators should no longer appear

https://claude.ai/code/session_01RCdxNaKG7Rg4CRMh7kXu7z

simulate() always pushes a StateUpdate at time=0 as the first replay
entry. The first worker call correctly strips it, but subsequent calls
included it in the data sent to the main thread. This StateUpdate
contains snapshots of every circle, causing the collision preview
renderer to show all balls at stale positions — appearing as desynchronized
collision indicators that vanish before the actual collisions occur.

Strip the StateUpdate from subsequent simulation batches, matching the
behavior of the first batch.

https://claude.ai/code/session_01RCdxNaKG7Rg4CRMh7kXu7z
@cloudflare-workers-and-pages
Copy link
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
balls 0a814b2 Commit Preview URL

Branch Preview URL
Mar 24 2026, 08:26 PM

@github-actions
Copy link

Benchmark Comparison

Benchmark Baseline (ops/sec) PR (ops/sec) Change
10 circles / 60s 202.77 246.16 +21.40% 🚀
20 circles / 60s 143.69 137.13 -4.57% ⚠️
40 circles / 60s 54.55 50.41 -7.58% ⚠️
80 circles / 60s 13.92 13.75 -1.21% ➡️
150 circles / 60s 3.39 3.51 +3.48%
300 circles / 60s 1.47 1.54 +4.98%
500 circles / 60s 0.77 0.78 +1.49% ➡️
1000 circles / 60s 0.33 0.33 +1.42% ➡️

Overall: +7.78% ✅


Merge base: 46a5cce | PR commit: 0a814b2 | 2026-03-24 20:27 UTC

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.

2 participants