From 4205cd905bcae4f65a292ad42e69bd0b81fc5a1e Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Fri, 15 May 2026 11:31:53 +0800 Subject: [PATCH] Clear pending destroy on createPage (a known safepoint). This allows pending destroys that have been accumulated to be cleaned up. In normal operations, this likely isn't going to happen. But we see a some unit tests create _many_ pages that never have the change to be cleaned up. The result is that the next "normal" unit test, which actually runs enough through Runner to trigger the cleanup, pays a huge cleanup price. Arguably, for a test-only solution, we could create a session per test, or have explicit cleanup in the test. But having 1 long-lasting session is useful as it can show us these potential pitfalls AND, it isn't impossible that a real-world case runs into similar issues. --- src/browser/Session.zig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/browser/Session.zig b/src/browser/Session.zig index d24a4abc..7d4a6895 100644 --- a/src/browser/Session.zig +++ b/src/browser/Session.zig @@ -216,6 +216,10 @@ fn installNewActivePage(self: *Session, frame_id: u32) !*Frame { // the pointer on Frame is just returned as a convenience pub fn createPage(self: *Session) !*Frame { lp.assert(self._active == null, "Session.createPage - page not null", .{}); + + // Drain any pending Page deinits now, while we're at a known-safe point + self.processQueuedDestroyed(); + if (comptime IS_DEBUG) { log.debug(.browser, "create page", .{}); }