Remove root context check from Env

This was only added [very briefly] when Env managed Origins, which it no longer
does.
This commit is contained in:
Karl Seguin
2026-03-11 08:21:35 +08:00
parent f6d0e484b0
commit dc3d2e9790
4 changed files with 5 additions and 14 deletions

View File

@@ -332,12 +332,11 @@ pub fn deinit(self: *Page, abort_http: bool) void {
session.releaseArena(qn.arena);
}
const is_root = self.parent == null;
session.browser.env.destroyContext(self.js, is_root);
session.browser.env.destroyContext(self.js);
self._script_manager.shutdown = true;
if (is_root) {
if (self.parent == null) {
session.browser.http_client.abort();
} else if (abort_http) {
// a small optimization, it's faster to abort _everything_ on the root

View File

@@ -276,7 +276,7 @@ pub fn replacePage(self: *Session) !*Page {
var current = self.page.?;
const frame_id = current._frame_id;
current.deinit(false);
current.deinit(true);
self.resetPageResources();
self.browser.env.memoryPressureNotification(.moderate);

View File

@@ -342,7 +342,7 @@ pub fn createContext(self: *Env, page: *Page) !*Context {
return context;
}
pub fn destroyContext(self: *Env, context: *Context, is_root: bool) void {
pub fn destroyContext(self: *Env, context: *Context) void {
for (self.contexts[0..self.context_count], 0..) |ctx, i| {
if (ctx == context) {
// Swap with last element and decrement count
@@ -365,14 +365,6 @@ pub fn destroyContext(self: *Env, context: *Context, is_root: bool) void {
}
context.deinit();
if (is_root) {
// When the root is destroyed, all of our contexts should be gone.
// Origin cleanup happens in Session.resetPageResources.
if (comptime IS_DEBUG) {
std.debug.assert(self.context_count == 0);
}
}
}
pub fn runMicrotasks(self: *Env) void {

View File

@@ -759,7 +759,7 @@ const IsolatedWorld = struct {
pub fn removeContext(self: *IsolatedWorld) !void {
const ctx = self.context orelse return error.NoIsolatedContextToRemove;
self.browser.env.destroyContext(ctx, false);
self.browser.env.destroyContext(ctx);
self.context = null;
}