Move page out of arena so that the arena can be reset between navigates

This commit is contained in:
Karl Seguin
2025-12-23 16:26:28 +08:00
parent 7c755483b1
commit bbf58a2807
2 changed files with 6 additions and 5 deletions

View File

@@ -172,7 +172,7 @@ pub fn init(arena: Allocator, call_arena: Allocator, session: *Session) !*Page {
log.debug(.page, "page.init", .{});
}
const page = try arena.create(Page);
const page = try session.browser.allocator.create(Page);
page.arena = arena;
page.call_arena = call_arena;
@@ -197,11 +197,13 @@ pub fn deinit(self: *Page) void {
// registered a destructor (e.g. XMLHttpRequest).
// Should be called before we deinit the page, because these objects
// could be referencing it.
self._session.executor.removeContext();
const session = self._session;
session.executor.removeContext();
self._script_manager.shutdown = true;
self._session.browser.http_client.abort();
session.browser.http_client.abort();
self._script_manager.deinit();
session.browser.allocator.destroy(self);
}
fn reset(self: *Page, comptime initializing: bool) !void {
@@ -307,7 +309,6 @@ pub fn isSameOrigin(self: *const Page, url: [:0]const u8) !bool {
pub fn navigate(self: *Page, request_url: [:0]const u8, opts: NavigateOpts) !void {
const session = self._session;
if (self._parse_state != .pre) {
// it's possible for navigate to be called multiple times on the
// same page (via CDP). We want to reset the page between each call.

View File

@@ -10,7 +10,7 @@ const Slab = struct {
max_slot_count: usize,
bitset: std.bit_set.DynamicBitSetUnmanaged,
chunks: std.ArrayListUnmanaged([]u8),
chunks: std.ArrayList([]u8),
pub fn init(
allocator: Allocator,