mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-02 14:19:48 +00:00
LibWeb: Fix endless spinning in apply_the_history_step()
While waiting for a task that populates a session history entry, we can't limit the processing of the event loop to the `NavigationAndTraversal` task source. This is because fetching uses the `Networking` task source, which also needs to be processed. Since making a fetch request might take some time, we want to process everything on the event loop while waiting, to avoid blocking user interactions. It is still possible to use `spin_processing_tasks_with_source_until()` on subsequent steps of `apply_the_history_step()`. Also modifies test that was flaky.
This commit is contained in:
parent
baf589deef
commit
609a72f7c7
Notes:
sideshowbarker
2024-07-18 05:01:22 +09:00
Author: https://github.com/kalenikaliaksandr
Commit: 609a72f7c7
Pull-request: https://github.com/SerenityOS/serenity/pull/23720
3 changed files with 17 additions and 13 deletions
|
@ -1 +1 @@
|
||||||
|
PASS: did not crash
|
||||||
|
|
|
@ -1,12 +1,16 @@
|
||||||
<script src="../include.js"></script>
|
<script src="../include.js"></script><div id="foo"><iframe></iframe><script>
|
||||||
<div id="foo">
|
setTimeout(function () {
|
||||||
<iframe></iframe>
|
foo.remove();
|
||||||
<script>
|
window.done = true;
|
||||||
setTimeout(function () {
|
}, 0);
|
||||||
foo.remove();
|
</script></div><iframe></iframe><script>
|
||||||
// Pass (didn't crash)
|
asyncTest(function (done) {
|
||||||
internals.signalTextTestIsDone();
|
let internalId;
|
||||||
|
internalId = setInterval(function () {
|
||||||
|
if (window.done) {
|
||||||
|
clearInterval(internalId);
|
||||||
|
done();
|
||||||
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
</script>
|
});
|
||||||
</div>
|
</script>PASS: did not crash
|
||||||
<iframe></iframe>
|
|
||||||
|
|
|
@ -572,7 +572,7 @@ TraversableNavigable::HistoryStepResult TraversableNavigable::apply_the_history_
|
||||||
// AD-HOC: Since currently populate_session_history_entry_document does not run in parallel
|
// AD-HOC: Since currently populate_session_history_entry_document does not run in parallel
|
||||||
// we call spin_until to interrupt execution of this function and let document population
|
// we call spin_until to interrupt execution of this function and let document population
|
||||||
// to complete.
|
// to complete.
|
||||||
main_thread_event_loop().spin_processing_tasks_with_source_until(Task::Source::NavigationAndTraversal, [&] {
|
main_thread_event_loop().spin_until([&] {
|
||||||
return !changing_navigable_continuations.is_empty() || completed_change_jobs == total_change_jobs;
|
return !changing_navigable_continuations.is_empty() || completed_change_jobs == total_change_jobs;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue