Bolt: Reduce GC pressure in WebGL animation loop #46

Open
ragusa-it wants to merge 1 commits from bolt-optimize-gradientblinds-gc-6327826835632059233 into main
ragusa-it commented 2026-02-01 02:08:45 +00:00 (Migrated from github.com)

💡 What: Replaced immutable object creation in GradientBlinds's requestAnimationFrame loop and pointermove handler with mutable ref updates.
🎯 Why: High-frequency object allocation (one per frame/event) creates significant Garbage Collection pressure, which can cause frame drops in smooth animations.
📊 Impact: Reduces object allocation to zero during the animation loop and pointer events.
🔬 Measurement: Verified via code review that no new objects are allocated in the hot path. Manual verification of logic correctness due to environment limitations.


PR created automatically by Jules for task 6327826835632059233 started by @ragusa-it

💡 **What**: Replaced immutable object creation in `GradientBlinds`'s `requestAnimationFrame` loop and `pointermove` handler with mutable ref updates. 🎯 **Why**: High-frequency object allocation (one per frame/event) creates significant Garbage Collection pressure, which can cause frame drops in smooth animations. 📊 **Impact**: Reduces object allocation to zero during the animation loop and pointer events. 🔬 **Measurement**: Verified via code review that no new objects are allocated in the hot path. Manual verification of logic correctness due to environment limitations. --- *PR created automatically by Jules for task [6327826835632059233](https://jules.google.com/task/6327826835632059233) started by @ragusa-it*
google-labs-jules[bot] commented 2026-02-01 02:08:45 +00:00 (Migrated from github.com)

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

👋 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 `@jules`. You can find this option in the **Pull Request** section of your [global Jules UI settings](https://jules.google.com/settings). You can always switch back! New to Jules? Learn more at [jules.google/docs](https://jules.google/docs). --- *_For security, I will only act on instructions from the user who triggered this task._*
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2026-02-01 02:11:17 +00:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull request overview

This PR optimizes the GradientBlinds WebGL animation component by eliminating object allocations in high-frequency code paths (animation loop and pointer event handlers). The optimization replaces immutable object creation with mutable ref updates, specifically converting pointerPosRef from a nullable object pattern to a stable object with an active boolean flag, and mutating array elements in place rather than creating new arrays.

Changes:

  • Replaced null-check pattern for pointer position with an active boolean flag in a stable object reference
  • Changed all array reassignments to element-wise mutations for mouseTargetRef and uniforms.iMouse.value
  • Added clear documentation explaining the rationale for value copying in the no-dampening case

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

## Pull request overview This PR optimizes the `GradientBlinds` WebGL animation component by eliminating object allocations in high-frequency code paths (animation loop and pointer event handlers). The optimization replaces immutable object creation with mutable ref updates, specifically converting `pointerPosRef` from a nullable object pattern to a stable object with an `active` boolean flag, and mutating array elements in place rather than creating new arrays. **Changes:** - Replaced null-check pattern for pointer position with an `active` boolean flag in a stable object reference - Changed all array reassignments to element-wise mutations for `mouseTargetRef` and `uniforms.iMouse.value` - Added clear documentation explaining the rationale for value copying in the no-dampening case --- 💡 <a href="/ragusa-it/ragusaitweb/new/main/.github/instructions?filename=*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin bolt-optimize-gradientblinds-gc-6327826835632059233:bolt-optimize-gradientblinds-gc-6327826835632059233
git checkout bolt-optimize-gradientblinds-gc-6327826835632059233
Sign in to join this conversation.