Skip to content

perf(web): pool and reuse layout components across layout transitions - #904

Merged
kyasbal merged 2 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-ltpymuqlmyxu
Aug 26, 2026
Merged

kyasbal merged 2 commits into
GoogleCloudPlatform:mainfrom
kyasbal:push-ltpymuqlmyxu

Conversation

@kyasbal

@kyasbal kyasbal commented Aug 26, 2026

Copy link
Copy Markdown
Member

Summary

Prevent recreation of expensive components (Timeline, Logs, History, Graph) when switching layouts from the header menu or shortcuts (Ctrl+1, Ctrl+2, Ctrl+3).

Changes

  • LayoutService Pooling: Detaches and pools Angular ComponentRef instances on layout change, cleanly reattaching their DOM elements into new GoldenLayout containers within the same JS execution frame.
  • Resource Retention: Keeps WebGL context, shaders, and log histogram caches intact for instantaneous layout switching without loading spinner.
  • Tab Close vs Layout Switch: Preserves pool on layout switch, but cleanly destroys (ComponentRef.destroy()) components on explicit tab close ('x').
  • Surplus Management: Automatically destroys extra timeline instances created by the user if they are not used in the newly selected layout.
  • Testing: Added layout.service.spec.ts unit tests verifying reuse, surplus destruction, and lifecycle disposal on ngOnDestroy.

Verification

  • make test-web (766/766 passed)
  • make lint-web (0 errors)
  • make format-web
  • make build-storybook
  • make pre-commit
Prevent recreation of expensive components (Timeline, Logs, History, Graph)
when switching layouts from the header menu or shortcuts.
LayoutService now detaches and pools ComponentRef instances, cleanly reattaching
their DOM elements when the new layout loads. This preserves the WebGL context,
shaders, and histogram calculations for immediate restoration without lag.
Surplus instances (e.g. extra timelines) are cleanly destroyed upon layout load.
@kyasbal kyasbal added the type:bug Something isn't working as expected label Aug 26, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces component pooling and caching in LayoutService to reuse Angular components (such as Timeline, Log, History, and Graph) when switching layouts, accompanied by comprehensive unit tests. The reviewer provided valuable feedback, suggesting to detach change detection for pooled components to avoid unnecessary CPU overhead, and to wrap DOM-manipulating test cases in try...finally blocks to ensure proper cleanup even upon test failures.

@kyasbal
kyasbal enabled auto-merge August 26, 2026 01:48
@kyasbal
kyasbal disabled auto-merge August 26, 2026 01:48
@kyasbal
kyasbal merged commit a680d39 into GoogleCloudPlatform:main Aug 26, 2026
16 checks passed
@kyasbal
kyasbal deleted the push-ltpymuqlmyxu branch August 26, 2026 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Something isn't working as expected

1 participant