Conversation
📊 Bundle Size Comparison
👀 Notable resultsStatic test results:No major changes. Dynamic test results:No major changes. 📋 All resultsClick to reveal the results table (344 entries).
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu. |
|
pkg.pr.new packages benchmark commit |
There was a problem hiding this comment.
Pull request overview
This PR cleans up multiple TypeGPU docs examples by standardizing animation timing (RAF timestamp), improving cleanup (canceling RAF), removing an obsolete “copy-error” example + test, and tightening GPU-side typing to avoid implicit casts.
Changes:
- Removed the
copy-errordocs example and its corresponding test. - Refactored many examples to use RAF
timestamp/lastTimefor delta-time calculations and to cancel scheduled frames on cleanup. - Adjusted various shader/example code paths to remove implicit casts (e.g., explicit
d.f32(...), stricter comparisons).
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/typegpu/tests/examples/individual/copy-error.test.ts | Removes the “copy error” example test from the package test suite. |
| apps/typegpu-docs/src/examples/tests/copy-error/meta.json | Removes docs metadata for the deleted “copy-error” example. |
| apps/typegpu-docs/src/examples/tests/copy-error/index.ts | Removes the deleted “copy-error” example implementation. |
| apps/typegpu-docs/src/examples/tests/copy-error/index.html | Removes the deleted “copy-error” example page content. |
| apps/typegpu-docs/src/examples/threejs/compute-cloth/verlet.ts | Makes isFixed check explicit (isFixed === 1) to avoid truthy casting. |
| apps/typegpu-docs/src/examples/simulation/slime-mold/index.ts | Switches first-frame timing to lastTime: number | null and uses RAF timestamp for dt. |
| apps/typegpu-docs/src/examples/simulation/slime-mold-3d/index.ts | Uses RAF timestamp parameter instead of calling performance.now() inside the loop. |
| apps/typegpu-docs/src/examples/simulation/game-of-life/index.ts | Tracks RAF id and cancels it during cleanup. |
| apps/typegpu-docs/src/examples/simulation/fluid-with-atomics/index.ts | Uses nullable lastTime and RAF timestamp to compute dt safely. |
| apps/typegpu-docs/src/examples/simulation/fluid-double-buffering/index.ts | Replaces “disposed flag” loop with RAF id cancellation; uses RAF timestamp in tick. |
| apps/typegpu-docs/src/examples/simulation/confetti/index.ts | Replaces “disposed flag” loop with RAF id cancellation and RAF timestamp dt. |
| apps/typegpu-docs/src/examples/simulation/boids/index.ts | Replaces “disposed flag” loop with RAF id cancellation. |
| apps/typegpu-docs/src/examples/simple/ripple-cube/post-processing.ts | Removes implicit casts by making blur offset multiplication explicitly f32. |
| apps/typegpu-docs/src/examples/rendering/two-boxes/index.ts | Replaces “disposed flag” loop with RAF id cancellation and simplifies frame scheduling. |
| apps/typegpu-docs/src/examples/rendering/point-light-shadow/index.ts | Tightens GPU numeric types and adds RAF id tracking for cleanup. |
| apps/typegpu-docs/src/examples/rendering/jelly-switch/index.ts | Removes implicit casts by making shader constants explicitly f32. |
| apps/typegpu-docs/src/examples/rendering/jelly-slider/index.ts | Removes implicit casts by making shader constants explicitly f32. |
| apps/typegpu-docs/src/examples/rendering/function-visualizer/index.ts | Changes uniform initialization/write flow and refactors resize logic into a shared updater. |
| apps/typegpu-docs/src/examples/rendering/disco/index.ts | Switches to RAF timestamp-based time uniform and adds RAF cancellation on cleanup. |
| apps/typegpu-docs/src/examples/rendering/clouds/index.ts | Switches to RAF timestamp-based time uniform and keeps RAF cancellation on cleanup. |
| apps/typegpu-docs/src/examples/rendering/box-raytracing/index.ts | Replaces “disposed flag” loop with RAF id cancellation and RAF timestamp dt. |
| apps/typegpu-docs/src/examples/rendering/3d-fish/index.ts | Replaces “disposed flag” loop with RAF id cancellation (but leaves a timeout path). |
| apps/typegpu-docs/src/examples/algorithms/mnist-inference/index.ts | Replaces “disposed flag” loop with RAF id cancellation. |
Comments suppressed due to low confidence (1)
apps/typegpu-docs/src/examples/rendering/3d-fish/index.ts:84
- The
setTimeoutcallback inenqueuePresetChanges()no longer checks whether the example has been cleaned up. IfonCleanup()runs before the 300ms timeout fires, this callback can still write to GPU buffers / touch DOM afterroot.destroy(), causing errors. Store the timeout id andclearTimeout()inonCleanup(), or reintroduce a disposed/aborted guard in the callback.
fishBehaviorBuffer.write(presets.init);
setTimeout(() => {
fishBehaviorBuffer.write(presets.default);
spinnerBackground.style.display = 'none';
speedMultiplier = 1;
}, 300);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Changes:
cancelAnimationFrameinstead ofdisposed,timestampinstead oftime.now(),performance.now()