playwright/packages/trace-viewer
Simon Knott b3d767fa14
fix(trace viewer): fix memory leak (#32379)
In the `visit` method, we currently cache the rendered HTML for every
walked node. This re-use works well for traces that consist mostly of
references to earlier snapshots.
But for traces that don't share much, this is a large memory overhead
and leads to the memory crash documented in
https://github.com/microsoft/playwright/issues/32336. For the algocracks
amongst you, the current memory usage for an html tree $h$ is
$\mathcal{O}(|h| * \text{height}(h))$.

This PR removes that cache from the nodes and replaces it with a
snapshot-level cache, fixing the memory crash.
Traces *without* reference should not see a performance impact from
this.
Traces *with* references will have slower initial rendering, but
re-rendering maintains speed because of the snapshot-level cache.

Closes https://github.com/microsoft/playwright/issues/32336

---------

Signed-off-by: Simon Knott <info@simonknott.de>
Co-authored-by: Max Schmitt <max@schmitt.mx>
2024-09-04 09:57:15 +02:00
..
public chore: use SVG icons for web apps (#26564) 2023-08-21 18:33:02 +02:00
src fix(trace viewer): fix memory leak (#32379) 2024-09-04 09:57:15 +02:00
.gitignore fix(debug): do not pause on internal calls, update ct docs (#14018) 2022-05-07 19:56:25 -07:00
bundle.ts chore: address deprecated Vite warnings (#31618) 2024-07-10 22:32:08 +02:00
embedded.html feature(trace-viewer): embedded mode support PoC (#30885) 2024-06-28 10:36:11 -07:00
index.html chore: use SVG icons for web apps (#26564) 2023-08-21 18:33:02 +02:00
package.json chore: address deprecated Vite warnings (#31618) 2024-07-10 22:32:08 +02:00
snapshot.html fix(trace-viewer): fix snapshot.html (#31033) 2024-05-28 13:14:22 -07:00
tsconfig.json chore: make @playwright/test depend on playwright (#26946) 2023-09-08 14:23:35 -07:00
tsconfig.node.json chore: address deprecated Vite warnings (#31618) 2024-07-10 22:32:08 +02:00
uiMode.html chore: use SVG icons for web apps (#26564) 2023-08-21 18:33:02 +02:00
vite.config.ts chore: address deprecated Vite warnings (#31618) 2024-07-10 22:32:08 +02:00
vite.sw.config.ts chore: address deprecated Vite warnings (#31618) 2024-07-10 22:32:08 +02:00