mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00

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>