mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-28 14:43:28 +00:00
Merge pull request #1131 from lightpanda-io/microtask-queue-drain
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / browser fetch (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
Some checks failed
e2e-test / zig build release (push) Has been cancelled
e2e-test / demo-scripts (push) Has been cancelled
e2e-test / cdp-and-hyperfine-bench (push) Has been cancelled
e2e-test / perf-fmt (push) Has been cancelled
zig-test / zig build dev (push) Has been cancelled
zig-test / browser fetch (push) Has been cancelled
zig-test / zig test (push) Has been cancelled
zig-test / perf-fmt (push) Has been cancelled
drain micro task queue before reset ExecutionWorld and page
This commit is contained in:
@@ -231,6 +231,12 @@ pub fn createContext(self: *ExecutionWorld, page: *Page, enter: bool, global_cal
|
||||
}
|
||||
|
||||
pub fn removeContext(self: *ExecutionWorld) void {
|
||||
// Force running the micro task to drain the queue before reseting the
|
||||
// context arena.
|
||||
// Tasks in the queue are relying to the arena memory could be present in
|
||||
// the queue. Running them later could lead to invalid memory accesses.
|
||||
self.env.runMicrotasks();
|
||||
|
||||
self.context.?.deinit();
|
||||
self.context = null;
|
||||
_ = self.context_arena.reset(.{ .retain_with_limit = CONTEXT_ARENA_RETAIN });
|
||||
|
||||
@@ -161,6 +161,9 @@ pub const Page = struct {
|
||||
}
|
||||
|
||||
fn reset(self: *Page) void {
|
||||
// Force running the micro task to drain the queue.
|
||||
self.session.browser.env.runMicrotasks();
|
||||
|
||||
self.scheduler.reset();
|
||||
self.http_client.abort();
|
||||
self.script_manager.reset();
|
||||
|
||||
Reference in New Issue
Block a user