Skip to content

fix: add keydownHandler and impove performance observers to inspector#160

Merged
dermatz merged 2 commits intomainfrom
fix/refactor-inspector
Apr 10, 2026
Merged

fix: add keydownHandler and impove performance observers to inspector#160
dermatz merged 2 commits intomainfrom
fix/refactor-inspector

Conversation

@dermatz
Copy link
Copy Markdown
Member

@dermatz dermatz commented Apr 10, 2026

This pull request enhances the robustness and maintainability of the inspector.js module by improving event handler management, ensuring proper cleanup of resources, and refactoring some UI rendering logic. The most significant changes include explicit tracking and cleanup of event listeners and performance observers, as well as the removal of several rendering methods related to performance metrics.

Event handler and observer management improvements:

  • Added a keydownHandler property to explicitly track the keyboard event handler, and updated setupKeyboardShortcuts to register and store this handler for later removal. [1] [2] [3]
  • Introduced a performanceObservers array to track all registered PerformanceObserver instances, ensuring they are properly disconnected during cleanup. Each observer is now pushed to this array after creation. [1] [2] [3] [4] [5] [6] [7]

Resource cleanup improvements:

  • Added a comprehensive destroy method that removes the keyboard event listener, disconnects all performance observers, closes the inspector if open, and removes all injected DOM elements to prevent memory leaks and unintended side effects.

UI rendering logic refactoring:

  • Removed the renderRenderTimeSection, renderDOMComplexitySection, renderWebVitalsSection, and renderPageTimingsSection methods, simplifying the codebase and possibly centralizing or eliminating redundant UI rendering logic. [1] [2]

Minor code cleanup:

  • Removed the generation of a unique SVG gradient ID for the floating button, likely as part of UI simplification.

Copilot AI review requested due to automatic review settings April 10, 2026 11:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves lifecycle management in inspector.js by explicitly tracking/removing event listeners and PerformanceObserver instances, and simplifying the Performance tab rendering.

Changes:

  • Track and clean up the document keydown handler via a dedicated keydownHandler reference.
  • Track created PerformanceObserver instances in performanceObservers and disconnect them during teardown.
  • Add a destroy() teardown routine and simplify Performance tab UI rendering by removing several rendering sections.

Comment thread src/view/frontend/web/js/inspector.js Outdated
@dermatz dermatz merged commit 5639b87 into main Apr 10, 2026
13 checks passed
@dermatz dermatz deleted the fix/refactor-inspector branch April 10, 2026 11:41
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.

2 participants