Skip to content

Commit f5761ee

Browse files
committed
Init netsurf at page creation
1 parent b5eea21 commit f5761ee

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
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);

0 commit comments

Comments
 (0)