mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-22 04:34:44 +00:00
Run the message loop more!
In https://github.com/lightpanda-io/browser/pull/1651 we started to run the message loop a lot more. One specific case we added for `fetch` was when there were no scheduled tasks or HTTP, but background tasks, we'd wait for them to complete. One case we missed though is if WE do have a schedule tasks, but it's too far into the future. In that case, we would just exit. This now adds the same logic for checking and waiting for any background tasks in that case.
This commit is contained in:
@@ -261,7 +261,7 @@ fn _wait(self: *Session, page: *Page, wait_ms: u32) !WaitResult {
|
|||||||
std.debug.assert(http_client.intercepted == 0);
|
std.debug.assert(http_client.intercepted == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ms: u64 = ms_to_next_task orelse blk: {
|
var ms: u64 = ms_to_next_task orelse blk: {
|
||||||
if (wait_ms - ms_remaining < 100) {
|
if (wait_ms - ms_remaining < 100) {
|
||||||
if (comptime builtin.is_test) {
|
if (comptime builtin.is_test) {
|
||||||
return .done;
|
return .done;
|
||||||
@@ -288,8 +288,14 @@ fn _wait(self: *Session, page: *Page, wait_ms: u32) !WaitResult {
|
|||||||
// Same as above, except we have a scheduled task,
|
// Same as above, except we have a scheduled task,
|
||||||
// it just happens to be too far into the future
|
// it just happens to be too far into the future
|
||||||
// compared to how long we were told to wait.
|
// compared to how long we were told to wait.
|
||||||
|
if (!browser.hasBackgroundTasks()) {
|
||||||
return .done;
|
return .done;
|
||||||
}
|
}
|
||||||
|
// _we_ have nothing to run, but v8 is working on
|
||||||
|
// background tasks. We'll wait for them.
|
||||||
|
browser.waitForBackgroundTasks();
|
||||||
|
ms = 20;
|
||||||
|
}
|
||||||
|
|
||||||
// We have a task to run in the not-so-distant future.
|
// We have a task to run in the not-so-distant future.
|
||||||
// You might think we can just sleep until that task is
|
// You might think we can just sleep until that task is
|
||||||
|
|||||||
Reference in New Issue
Block a user