mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
cleanupany incomplete scheduled_navigation on renavigate or page.deinit
This commit is contained in:
@@ -332,6 +332,10 @@ pub fn deinit(self: *Page) void {
|
|||||||
// stats.print(&stream) catch unreachable;
|
// stats.print(&stream) catch unreachable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (self._queued_navigation) |qn| {
|
||||||
|
self.arena_pool.release(qn.arena);
|
||||||
|
}
|
||||||
|
|
||||||
const session = self._session;
|
const session = self._session;
|
||||||
session.browser.env.destroyContext(self.js);
|
session.browser.env.destroyContext(self.js);
|
||||||
|
|
||||||
@@ -585,6 +589,10 @@ fn scheduleNavigationWithArena(self: *Page, arena: Allocator, request_url: []con
|
|||||||
.url = resolved_url,
|
.url = resolved_url,
|
||||||
.priority = priority,
|
.priority = priority,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (self._queued_navigation) |existing| {
|
||||||
|
self.arena_pool.release(existing.arena);
|
||||||
|
}
|
||||||
self._queued_navigation = qn;
|
self._queued_navigation = qn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -917,9 +925,9 @@ fn pageDoneCallback(ctx: *anyopaque) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn pageErrorCallback(ctx: *anyopaque, err: anyerror) void {
|
fn pageErrorCallback(ctx: *anyopaque, err: anyerror) void {
|
||||||
log.err(.page, "navigate failed", .{ .err = err, .type = self._type });
|
|
||||||
|
|
||||||
var self: *Page = @ptrCast(@alignCast(ctx));
|
var self: *Page = @ptrCast(@alignCast(ctx));
|
||||||
|
|
||||||
|
log.err(.page, "navigate failed", .{ .err = err, .type = self._type });
|
||||||
self._parse_state = .{ .err = err };
|
self._parse_state = .{ .err = err };
|
||||||
|
|
||||||
// In case of error, we want to complete the page with a custom HTML
|
// In case of error, we want to complete the page with a custom HTML
|
||||||
|
|||||||
@@ -176,8 +176,10 @@ pub fn wait(self: *Session, wait_ms: u32) WaitResult {
|
|||||||
|
|
||||||
switch (wait_result) {
|
switch (wait_result) {
|
||||||
.done => {
|
.done => {
|
||||||
const qn = page._queued_navigation orelse return .done;
|
if (page._queued_navigation == null) {
|
||||||
page = self.processScheduledNavigation(qn) catch return .done;
|
return .done;
|
||||||
|
}
|
||||||
|
page = self.processScheduledNavigation(page) catch return .done;
|
||||||
},
|
},
|
||||||
else => |result| return result,
|
else => |result| return result,
|
||||||
}
|
}
|
||||||
@@ -322,8 +324,12 @@ fn _wait(self: *Session, page: *Page, wait_ms: u32) !WaitResult {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn processScheduledNavigation(self: *Session, qn: *Page.QueuedNavigation) !*Page {
|
fn processScheduledNavigation(self: *Session, current_page: *Page) !*Page {
|
||||||
const browser = self.browser;
|
const browser = self.browser;
|
||||||
|
|
||||||
|
const qn = current_page._queued_navigation.?;
|
||||||
|
// take ownership of the page's queued navigation
|
||||||
|
current_page._queued_navigation = null;
|
||||||
defer browser.arena_pool.release(qn.arena);
|
defer browser.arena_pool.release(qn.arena);
|
||||||
|
|
||||||
const page_id, const parent = blk: {
|
const page_id, const parent = blk: {
|
||||||
|
|||||||
Reference in New Issue
Block a user