Send idle messages as part of messaging loop

This commit is contained in:
Martin Robinson 2025-07-31 10:13:41 +02:00
parent f5472c1295
commit 31096e1a0f
3 changed files with 18 additions and 6 deletions

View file

@ -3723,12 +3723,7 @@ impl Document {
receiver.recv().unwrap();
}
let result = self.window().reflow(ReflowGoal::UpdateTheRendering, can_gc);
self.window()
.maybe_send_idle_document_state_to_constellation();
result
self.window().reflow(ReflowGoal::UpdateTheRendering, can_gc)
}
pub(crate) fn id_map(&self) -> Ref<HashMapTracedValues<Atom, Vec<Dom<Element>>>> {

View file

@ -2345,6 +2345,10 @@ impl Window {
return;
}
if self.Document().needs_rendering_update() {
return;
}
// When all these conditions are met, notify the constellation
// that this pipeline is ready to write the image (from the script thread
// perspective at least).

View file

@ -1437,6 +1437,18 @@ impl ScriptThread {
);
}
fn maybe_send_idle_document_state_to_constellation(&self) {
if !opts::get().wait_for_stable_image {
return;
}
for (_, document) in self.documents.borrow().iter() {
document
.window()
.maybe_send_idle_document_state_to_constellation();
}
}
/// Handle incoming messages from other tasks and the task queue.
fn handle_msgs(&self, can_gc: CanGc) -> bool {
// Proritize rendering tasks and others, and gather all other events as `sequential`.
@ -1647,6 +1659,7 @@ impl ScriptThread {
}
self.maybe_schedule_rendering_opportunity_after_ipc_message(can_gc);
self.maybe_send_idle_document_state_to_constellation();
true
}