File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff 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 );
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments