⚡ Fix excessive Redux dispatches in Composition component#101
⚡ Fix excessive Redux dispatches in Composition component#101Godzilla675 wants to merge 1 commit intomainfrom
Conversation
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Summary of ChangesHello @Godzilla675, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request resolves a critical performance issue within the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR fixes a performance issue in the Composition component where Redux's setCurrentTime action was being dispatched on every animation frame due to a missing ref update. The fix adds a single line that updates previousTime.current after dispatching, ensuring the threshold check works as intended.
Changes:
- Added
previousTime.current = currentTimeInSecondsupdate after Redux dispatch to properly track time changes - Accidentally included a test file (
test_tsx.ts) that should be removed
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/web/app/components/editor/player/remotion/sequence/composition.tsx | Adds the missing ref update to fix excessive Redux dispatches (73% reduction in dispatch count) |
| test_tsx.ts | Test/debug file that should be removed before merging |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1 @@ | |||
| console.log('Hello from tsx') | |||
There was a problem hiding this comment.
This file appears to be a test or debugging artifact that was accidentally committed. It contains only a console.log statement and doesn't serve any purpose in the production codebase. This file should be removed before merging.
| console.log('Hello from tsx') |
There was a problem hiding this comment.
Code Review
This pull request correctly fixes a performance issue by preventing excessive Redux dispatches in the Composition component. The logic to update previousTime.current is sound. I've added a couple of suggestions for improvement: one to simplify the code by removing a redundant check, and another to remove a test file that appears to have been committed accidentally.
| if (currentTimeInSeconds !== undefined) { | ||
| dispatch(setCurrentTime(currentTimeInSeconds)); | ||
| previousTime.current = currentTimeInSeconds; | ||
| } |
There was a problem hiding this comment.
The check currentTimeInSeconds !== undefined is redundant. currentTimeInSeconds is calculated as frame / fps, where frame is a number from useCurrentFrame() and fps is a constant number. The result will always be a number, so this check is unnecessary. You can simplify the code by removing this conditional block.
dispatch(setCurrentTime(currentTimeInSeconds));
previousTime.current = currentTimeInSeconds;
| @@ -0,0 +1 @@ | |||
| console.log('Hello from tsx') | |||
This PR fixes a performance issue in the
Compositioncomponent wheresetCurrentTimewas being dispatched on every frame due to a missing update topreviousTime.current.💡 What:
previousTime.currentafter dispatchingsetCurrentTimeinside theuseEffecthook.🎯 Why:
previousTime.currentref was never updated, causing the conditionMath.abs(currentTimeInSeconds - previousTime.current) > THRESHOLDto always be true after the initial threshold was crossed.setCurrentTimebeing dispatched on every frame (30 times per second), flooding the Redux store and causing unnecessary re-renders.📊 Measured Improvement:
PR created automatically by Jules for task 18266452197996712558 started by @Godzilla675