mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 23:23:28 +00:00
Do not reset transfer_arena if page navigation results in delayed navigation
We normally expect a navigation event to happen at some point after the page loads, like a puppeteer script clicking on a link. But, it's also possible for the main navigation event to result in a delayed navigation. For example, an html page with this JS: <script>top.location = '/';</script> Would result in a delayed navigation being called from the main navigate function. In these cases, we cannot clear the transfer_arena when navigate is completed, as its memory is needed by the new "sub" delayed navigation.
This commit is contained in:
@@ -128,7 +128,14 @@ pub const Session = struct {
|
||||
// it isn't null!
|
||||
std.debug.assert(self.page != null);
|
||||
|
||||
defer _ = self.browser.transfer_arena.reset(.{ .retain_with_limit = 1 * 1024 * 1024 });
|
||||
defer if (self.page) |*p| {
|
||||
if (!p.delayed_navigation) {
|
||||
// If, while loading the page, we intend to navigate to another
|
||||
// page, then we need to keep the transfer_arena around, as this
|
||||
// sub-navigation is probably using it.
|
||||
_ = self.browser.transfer_arena.reset(.{ .retain_with_limit = 1 * 1024 * 1024 });
|
||||
}
|
||||
};
|
||||
|
||||
// it's safe to use the transfer arena here, because the page will
|
||||
// eventually clone the URL using its own page_arena (after it gets
|
||||
|
||||
Reference in New Issue
Block a user