Skip to content

fix(studio): stop inactive Nebula animations - #1404

Draft
BrianNewsom wants to merge 2 commits into
mainfrom
fix-studio-nebula-animation-leak/brnewsom
Draft

fix(studio): stop inactive Nebula animations#1404
BrianNewsom wants to merge 2 commits into
mainfrom
fix-studio-nebula-animation-leak/brnewsom

Conversation

@BrianNewsom

@BrianNewsom BrianNewsom commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Summary

NeMo Studio kept the empty-chat Nebula animation running after the compact Assistant popover closed and after other empty-chat canvases unmounted. A single open and close of the top-bar Assistant was enough to leave the hidden animation consuming sustained renderer CPU; repeated chat lifecycles could additionally retain detached animation loops.

This change unmounts the compact Assistant thread when its popover closes, cancels the active animation frame during Nebula ref cleanup, and releases the retained animation state.

Changes

  • Unmount the compact Assistant thread when its popover closes instead of leaving its canvas hidden and active.
  • Track and cancel the currently scheduled requestAnimationFrame when Nebula unmounts or reinitializes.
  • Release the canvas, context, and particle references during cleanup.
  • Add regression coverage for both the Assistant close behavior and repeated Nebula mount/unmount cycles.

Type of Change

  • Code change (feature, bug fix, or refactor)
  • Code change with documentation updates
  • Documentation only
  • Contributor tooling or automation
  • CI, build, or test infrastructure

Quality Gates

  • Tests added or updated for changed behavior
  • Existing tests cover changed behavior — justification:
  • Tests not applicable — justification:
  • Documentation updated for user-visible behavior
  • Documentation not applicable — justification: the fix changes internal animation lifecycle behavior without changing a documented workflow or API.

Verification

  • Pull request title follows the repository's Conventional Commit format
  • Every commit includes an appropriate Signed-off-by: trailer
  • uv run pre-commit run -a passes, or any blocked checks are identified below
  • Targeted tests pass, or tests are marked not applicable above
  • No secrets, API keys, or credentials are included

Actual Studio reproduction

On main, with NeMo Assistant enabled:

  1. Open a workspace route that shows the top-bar NeMo Assistant button, such as Agents.
  2. Open NeMo Assistant once with an empty thread.
  3. Close the Assistant popover once. Repeated opening or navigation is not required.
  4. Leave the Studio tab open and inspect the renderer in Chrome Task Manager or DevTools Performance Monitor.

The KUI popover hides its content without unmounting it. Before this fix, the compact Assistant thread and its Nebula canvas therefore remained mounted after close, and requestAnimationFrame continued processing 250 particles plus 31,125 particle-pair connection checks every frame while the UI was hidden.

The actual bundled Studio frontend was run against its configured development backend in system Chrome. Chrome DevTools Protocol sampled five-second TaskDuration and ScriptDuration deltas on the Agents route.

Actual Studio state Mounted Nebulas Renderer task CPU JavaScript CPU
Before opening Assistant (main) 0 0.056% 0%
Empty Assistant visible (main) 1 12.79% 8.66%
After closing Assistant once (main) 1 8.94% 7.21%
After closing Assistant once (this fix) 0 0.0069–0.0153% across three runs 0%

With this fix, closing the popover unmounts the compact thread; the shared Nebula cleanup cancels its frame, and the renderer returns to idle.

Detached-loop reproduction

The same shared empty state is used by model chat and full Assistant chat. On main, sending the first message or navigating away unmounts the empty state but leaves its frame loop active. A Playwright lifecycle harness automated ten mount/unmount cycles against the origin/main source and this branch:

Build Pending animation frames Renderer task CPU after unmount
origin/main 10 48.47–51.70% across three runs
This fix 0 0.011–0.019% across three runs

An unminified baseline CPU profile identified quadratic drawConnections as the dominant function, followed by canvas stroke, particle draw, and garbage collection. The fixed profile was idle.

Targeted validation:

  • pnpm --filter nemo-studio-ui test src/routes/agents/AssistantChatRoute/AssistantTopBarChat.test.tsx — passed (8 tests).
  • pnpm --filter @nemo/common test src/components/Nebula/index.test.tsx — passed (1 test).
  • pnpm --filter nemo-studio-ui test — passed (315 files, 2,933 tests).
  • pnpm --filter @nemo/common test — passed (121 files, 1,496 tests).
  • pnpm --filter nemo-studio-ui typecheck — passed.
  • pnpm --filter nemo-studio-ui lint — passed.
  • Targeted Prettier check for all five changed files — passed.
  • VITE_FF_ASSISTANT_STUDIO_ENABLED=true pnpm --filter nemo-studio-ui build:dev — passed; this build was used for the actual-app Chrome measurements.
  • pnpm --filter='...[origin/main]' run --parallel --if-present typecheck — passed for affected Common and Studio packages.
  • pnpm --filter='...[origin/main]' run --parallel --if-present test:ci — passed with coverage before the Assistant-specific regression was added (Common: 1,496 tests; Studio: 2,898 tests); the updated full Studio suite above passed afterward.
  • uv run pre-commit run -a — code-related hooks passed, including Ruff, Ruff format, ty, config-reference validation, lock checks, copyright headers, UI lint-staged, merge-conflict detection, and Flox-lock validation. The overall command is blocked on host prerequisites unrelated to this change: helm-docs is not installed, and yq is unavailable to three toolchain-version consistency hooks.

Local pnpm commands ran with pnpm 10.34.5 under Node 24.18.0 because Flox is not installed on this host; the repository requests Node 22.23.2, so pnpm emitted an engine warning. All listed web checks still passed.

Signed-off-by: Brian Newsom <brnewsom@nvidia.com>
@github-actions github-actions Bot added the fix label Aug 19, 2026
@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor
Suite Lines Covered Line Rate Branch Rate
Unit Tests 34302/43320 79.2% 64.0%
Integration Tests 20266/41119 49.3% 22.0%

Signed-off-by: Brian Newsom <brnewsom@nvidia.com>
@BrianNewsom BrianNewsom changed the title fix(studio): cancel Nebula animation on unmount fix(studio): stop inactive Nebula animations Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant