Optimize WebGL motion performance - #15
Conversation
|
Warning Review limit reached
More reviews will be available in 46 minutes and 14 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. 📝 WalkthroughWalkthroughThis PR introduces a new ChangesMotion Pixel Ratio Optimization and Animation Refactor
Possibly Related PRs
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/webgl.ts (1)
366-376:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winReset the animation clock when motion is turned back on.
If this renderer has been running in static mode,
startTimestill points at the originalstart(). Re-enabling motion here makes the first animated frame jump away from theupdateAnimatedGeometry(0)state thatsetStaticUniforms()just uploaded.Suggested fix
update(nextOptions) { + const wasMotionEnabled = motion.enabled; rawOptions = { ...rawOptions, ...nextOptions }; options = resolveWebGLMeshGradientOptions(rawOptions); setStaticUniforms(); renderer.resize(); if (!running) return; - if (motion.enabled) requestLoop(); + if (motion.enabled) { + if (!wasMotionEnabled) { + startTime = performance.now(); + lastFrame = 0; + } + requestLoop(); + } else { cancelLoop(); render(performance.now()); } },🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/webgl.ts` around lines 366 - 376, The update function merges options and sets static uniforms but doesn't reset the animation clock when motion is re-enabled; modify update (the block that checks motion.enabled/else) to detect when motion.enabled is true and the renderer was previously not running or motion was previously disabled, then set startTime = performance.now() (and reset any related timing state like lastFrameTime if present) before calling requestLoop(); reference the update function, motion.enabled, requestLoop, cancelLoop, render, setStaticUniforms, and performance.now when making the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/webgl.ts`:
- Around line 366-376: The update function merges options and sets static
uniforms but doesn't reset the animation clock when motion is re-enabled; modify
update (the block that checks motion.enabled/else) to detect when motion.enabled
is true and the renderer was previously not running or motion was previously
disabled, then set startTime = performance.now() (and reset any related timing
state like lastFrameTime if present) before calling requestLoop(); reference the
update function, motion.enabled, requestLoop, cancelLoop, render,
setStaticUniforms, and performance.now when making the change.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 02f1c698-62b7-4791-962a-70b3a34bab0c
📒 Files selected for processing (5)
README.mddocs/API.mdsrc/webgl-react.tsxsrc/webgl.tstests/library.test.mjs
Summary
Tests
Summary by CodeRabbit
Release Notes
New Features
motionMaxPixelRatiooption to control device pixel density during animation playbackfpsconfiguration option for motion controlDocumentation
Tests