-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix transform animation jumping under CPU load #3463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Code ReviewSummaryThis PR fixes a critical bug where transform animations jump during rapid interruptions under CPU load. The root cause was correctly identified: WAAPI's ✅ Strengths
🔍 Issues & Concerns1. Critical:
|
When rapidly interrupting WAAPI animations under CPU load, the element would jump to incorrect positions. This was caused by using WAAPI's currentTime for sampling, which doesn't accurately reflect elapsed time when the main thread is blocked. The fix uses time.now() from the frameloop to track wall-clock elapsed time independently, ensuring accurate sampling regardless of main thread contention. - Add startedAt timestamp using time.now() in NativeAnimationExtended - Use elapsed wall-clock time for animation sampling instead of WAAPI currentTime - Add E2E test reproducing the rapid hover scenario - Document time.now() usage in CLAUDE.md 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
a2dbf9e to
b684181
Compare
Code ReviewI've reviewed this PR and here's my detailed feedback: ✅ Overall AssessmentThis is a well-executed fix for a subtle timing bug in WAAPI animations under CPU load. The approach is sound, well-documented, and properly tested. 🎯 Code Quality & Best PracticesStrengths:
Minor Issue - Clamp Usage: const delta = clamp(0, sampleDelta, sampleTime - sampleDelta)The
Question: Is this intentional? It seems like Suggested improvement: // Clamp delta to ensure we don't sample too far back when starting or under extreme CPU load
const delta = clamp(0, sampleDelta, sampleTime - sampleDelta)Or if the intent is simpler: const delta = Math.min(sampleDelta, elapsedTime)🐛 Potential Bugs
⚡ Performance ConsiderationsExcellent:
Note: The 🔒 Security ConcernsNo security issues identified. This is internal animation timing logic with no user input or external data handling. 🧪 Test CoverageStrong:
Suggestions:
📝 Documentation & CommentsExcellent:
🔧 Suggestions for Improvement
✨ Final VerdictLGTM with minor suggestions. This is a solid fix that:
The only hesitation is the delta calculation logic which seems overly complex for what appears to be Recommendation: ✅ Approve with suggestions for follow-up Great work! 🎉 |
Instead of relying on WAAPI's dynamic startTime (which changes on pause/resume), use a manualStartTime property that gets cleared by play() and time setter, allowing WAAPI to take over timing when appropriate. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code ReviewSummaryThis PR fixes a critical bug where transform animations would jump when rapidly interrupted under CPU load. The fix correctly uses wall-clock time from ✅ Strengths
🔍 Issues & Concerns1. Missing Test File
|
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code ReviewI've reviewed PR #3463 and here's my feedback: ✅ Strengths
🔍 Potential Issues & Questions1. Time Synchronization Concern (packages/motion-dom/src/animation/NativeAnimationExtended.ts:100)The fix uses const sampleTime =
this.manualStartTime !== null
? Math.max(sampleDelta, time.now() - this.manualStartTime)
: secondsToMilliseconds(this.finishedTime ?? this.time)Question: When 2. Missing Type Safety (packages/motion-dom/src/animation/NativeAnimation.ts:53)The protected manualStartTime: number | null = nullSuggestion: Consider documenting this in NativeAnimation's constructor or adding a comment explaining that this is intentionally used by subclasses. 3. Edge Case: Zero Delta (packages/motion-dom/src/animation/NativeAnimationExtended.ts:102)const delta = clamp(0, sampleDelta, sampleTime - sampleDelta)If motionValue.setWithVelocity(
sampleAnimation.sample(Math.max(0, sampleTime - delta)).value,
sampleAnimation.sample(sampleTime).value,
delta // Could be 0
)Concern: With 4. Test File Missing from DiffThe PR description mentions an E2E test file ( 5. Potential Race Condition (packages/motion-dom/src/animation/NativeAnimationExtended.ts:54-65)The overridden play() {
this.manualStartTime = null
super.play()
}Edge case: If 📊 Performance ConsiderationsPositive: Using Minor concern: Creating a new 🔒 Security ConsiderationsNo security concerns identified. This is pure animation timing logic with no user input or external data processing. 🧪 Test CoverageStrengths:
Recommendations:
📝 Code Style✅ Follows repository conventions:
🎯 Overall AssessmentThis is a solid fix for a tricky timing issue. The core approach is sound, but there are a few edge cases worth investigating:
Recommendation: Approve with minor revisions to address the delta edge case and ensure test coverage is complete. Great work on tracking down and fixing this CPU load timing issue! The |
Code ReviewSummaryThis PR fixes a subtle timing bug in transform animations when rapidly interrupting animations under CPU load. The fix uses wall-clock time tracking via Positive Aspects ✅
Issues and Concerns
|
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code Review: Fix transform animation jumping under CPU loadOverviewThis PR addresses a critical timing issue where WAAPI animations would jump to incorrect positions when rapidly interrupted under CPU load. The fix switches from using WAAPI's ✅ Strengths
|
The startTime getter returns manualStartTime when set, falling back to WAAPI's startTime. Both play() and time setter clear manualStartTime to allow WAAPI to take over timing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code Review - PR #3463SummaryThis PR fixes a critical bug where transform animations would jump when rapidly interrupted under CPU load. The fix correctly addresses the root cause by using wall-clock time (time.now()) instead of relying on WAAPI's currentTime, which doesn't accurately reflect elapsed time when the main thread is blocked. ✅ Strengths
🔍 Issues & Suggestions1. Missing E2E Test File
|
Code ReviewThanks for this fix! I've reviewed the changes and have some feedback on code quality, potential issues, and test coverage. ✅ Strengths
🔍 Potential Issues1. Critical:
|
Summary
currentTimedoesn't accurately reflect elapsed time when the main thread is blockedtime.now()from the frameloop to track wall-clock elapsed time independentlyChanges
startedAttimestamp usingtime.now()inNativeAnimationExtendedcurrentTimetime.now()usage in CLAUDE.mdTest plan
animate-transform-jump.html🤖 Generated with Claude Code