Fix live metrics memory leak

There are two main issues at play here:

1) web-vitals-inject.ts uses global arrays to monkeypatch Event
Listeners and Performance Observers (and their args!) and never removes
these when the Event Listeners and POs are finished with. I believe this
is the main memory leak. Gemini suggested a better alternative.

2) The web-vital.js library tracks the event entries into pendingGroups
for two reasons: i) to allow them to be emitted in the object should the
user wish to use them for some reason, and ii) to handle out of order
LoAFs. DevTools doesn't use them and also emits the entries right away
so does not benefit from holding on to them. This only is a problem for
really slow frames (as the demo in b/484342204 highlights) and we should
only keep the top 50 + 10, but that can still really add up and, as I
say, it is not actually needed for DevTools usage of web-vitals.js
anyway.

I'm going to do more clean up in web-vitals 5.2 (reducing the 50 to 5
and capping the queued entries to 5 as well, and Jack has a onIdleOrHidden fix as well), but for now this seems to solve the main issue in DevTools. We can have the Chat team test in Canary, once this lands.

Bug: 484342204
Change-Id: I7c4575289a4df76e8e29bee112aabc32831ad5d1
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/7644771
Reviewed-by: Jack Franklin <jacktfranklin@chromium.org>
Commit-Queue: Barry Pollard <barrypollard@chromium.org>
Reviewed-by: Paul Irish <paulirish@chromium.org>
4 files changed
tree: dcc3d449fc85866f559f8f8721ce63ff3807e73f
  1. .agents/
  2. .gemini/
  3. .github/
  4. .vscode/
  5. build_overrides/
  6. config/
  7. docs/
  8. extension-api/
  9. extensions/
  10. front_end/
  11. inspector_overlay/
  12. mcp/
  13. node_modules/
  14. scripts/
  15. test/
  16. third_party/
  17. v8/
  18. .clang-format
  19. .clang-format-ignore
  20. .editorconfig
  21. .env.template
  22. .geminiignore
  23. .git-blame-ignore-revs
  24. .gitallowed
  25. .gitattributes
  26. .gitignore
  27. .gitmodules
  28. .gn
  29. .mailmap
  30. .npmignore
  31. .npmrc
  32. .style.yapf
  33. .stylelintignore
  34. .stylelintrc.json
  35. AUTHORS
  36. BUILD.gn
  37. codereview.settings
  38. CONTRIBUTING.md
  39. DEPS
  40. DIR_METADATA
  41. eslint.config.mjs
  42. favicon.ico
  43. LICENSE
  44. OWNERS
  45. package-lock.json
  46. package.json
  47. PRESUBMIT.py
  48. README.md
  49. WATCHLISTS
README.md

Chrome DevTools frontend

npm package

The client-side of the Chrome DevTools, including all TypeScript & CSS to run the DevTools webapp.

Source code and documentation

The frontend is available on chromium.googlesource.com. Check out the Chromium DevTools documentation for instructions to set up, use, and maintain a DevTools front-end checkout, as well as design guidelines, and architectural documentation.

Source mirrors

DevTools frontend repository is mirrored on GitHub.

DevTools frontend is also available on NPM as the chrome-devtools-frontend package. It's not currently available via CJS or ES modules, so consuming this package in other tools may require some effort.

The version number of the npm package (e.g. 1.0.373466) refers to the Chromium commit position of latest frontend git commit. It's incremented with every Chromium commit, however the package is updated roughly daily.

Getting in touch

There are a few options to keep an eye on the latest and greatest of DevTools development: