Tests/LibWeb: Do not leak multiple GB of screenshots in the test runner

For every ref tests actual and expected screenshots are taken. These
screenshots are only needed while the individual test executes. However,
they are never freed during the run, leading to a continuous increase in
memory usage of the test runner while executing ref tests.

With the number of ref tests growing, this currently amounts to nearly 3
GB of uncompressed bitmap data being held in memory. Lets avoid that by
clearing the screenshot data at the end of each test. With this change
applied, the memory usage of test-web stays stable and below 100 MB for
the entire test run.
This commit is contained in:
InvalidUsernameException 2025-09-02 22:07:54 +02:00 committed by Jelle Raaijmakers
parent 18c0739bbb
commit a259ed4db6

View File

@ -50,6 +50,9 @@ void TestWebView::did_receive_screenshot(Badge<WebView::WebContentClient>, Gfx::
void TestWebView::on_test_complete(TestCompletion completion)
{
completion.test.actual_screenshot.clear();
completion.test.expectation_screenshot.clear();
m_pending_screenshot.clear();
m_pending_dialog = Web::Page::PendingDialog::None;
m_pending_prompt_text.clear();