Skip to content

Commit 884ec05

Browse files
authored
Merge pull request #628 from lightpanda-io/init_netsurf_at_page_creation
Init netsurf at page creation
2 parents f633edd + 9ab8a2c commit 884ec05

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/browser/browser.zig

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ pub const Session = struct {
152152
pub fn createPage(self: *Session) !*Page {
153153
std.debug.assert(self.page == null);
154154

155+
// Start netsurf memory arena.
156+
// We need to init this early as JS event handlers may be registered through Runtime.evaluate before the first html doc is loaded
157+
try parser.init();
158+
155159
const page_arena = &self.browser.page_arena;
156160
_ = page_arena.reset(.{ .retain_with_limit = 1 * 1024 * 1024 });
157161

@@ -393,9 +397,6 @@ pub const Page = struct {
393397
fn loadHTMLDoc(self: *Page, reader: anytype, charset: []const u8) !void {
394398
const arena = self.arena;
395399

396-
// start netsurf memory arena.
397-
try parser.init();
398-
399400
log.debug("parse html with charset {s}", .{charset});
400401

401402
const ccharset = try arena.dupeZ(u8, charset);

src/cdp/testing.zig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ const TestContext = struct {
121121
if (opts.html) |html| {
122122
if (bc.session_id == null) bc.session_id = "SID-X";
123123
parser.deinit();
124-
try parser.init();
125124
const page = try bc.session.createPage();
126125
page.doc = (try Document.init(html)).doc;
127126
}

0 commit comments

Comments
 (0)