control: an idle window keeps painting while a screenshot waits to be issued

The capture queue issues a request only after a few settled UI passes, but the control
server wakes one frame per request, so on an idle window a ui.screenshot was admitted,
got one pass and then waited until the transport's 60 s deadline. issue_captures now
requests a repaint while any capture is unissued (Captures::any_unissued documents that
the app keeps repainting while any is). Test: control::tests::a_screenshot_keeps_an_idle_window_painting_until_it_is_issued.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Dylan M. TaylorandClaude Opus 5.5 committed 2026-11-28 03:33:47 +00:00
1 parent bd1a419636
commit 6c329b6c72
2 files changed
+39

No files matched your search

+4
View File
@@ -41,6 +41,10 @@ impl SlideApp {
channel.captures.note_pass();
let finished = channel.captures.issue(&host, craft::ui::runtime::motion::now(), document);
control::finish_captures(self, &mut channel, finished);
// A capture settles over passes and waits out its delay; an idle window would draw no more of them.
if channel.captures.any_unissued() {
ui.ctx().request_repaint();
}
self.control = Some(channel);
}
}
+35
View File
@@ -967,6 +967,41 @@ mod tests {
Ok(())
}
/// A screenshot needs passes to settle before it is issued: an idle window keeps asking for them until it is.
#[test]
fn a_screenshot_keeps_an_idle_window_painting_until_it_is_issued() -> Result<(), Box<dyn Error>> {
let (sender, receiver) = mpsc::channel();
let mut harness = harness_with(
deckcraft_engine::Session::with_new(),
crate::Services::default(),
egui_kittest::Harness::builder().with_size(egui::vec2(1440.0, 900.0)).with_step_dt(1.0 / 60.0),
|platform| platform.control = Some(ControlChannel::new(receiver)),
);
let idle = |harness: &mut egui_kittest::Harness<'static, SlideApp>| {
(0..600).any(|_| {
harness.run_steps(1);
!harness.ctx.has_requested_repaint()
})
};
assert!(idle(&mut harness), "the window goes idle before the request");
let (request, _reply) = ControlRequest::new("ui.screenshot", json!({}));
sender.send(request).map_err(|_| "control channel closed")?;
let unissued =
|harness: &egui_kittest::Harness<'static, SlideApp>| harness.state().control.as_ref().is_some_and(|c| c.captures.any_unissued());
harness.run_steps(1);
assert!(unissued(&harness), "the request is admitted and settling");
for _ in 0..600 {
if !unissued(&harness) {
break;
}
assert!(harness.ctx.has_requested_repaint(), "a settling screenshot asks for the next pass");
std::thread::sleep(std::time::Duration::from_millis(2));
harness.run_steps(1);
}
assert!(!unissued(&harness), "the capture was issued");
Ok(())
}
/// A request from a client's own thread is answered by the UI thread's frame: the connection thread only
/// forwards it and asks for a repaint, so it never touches a running pass's state.
#[cfg(not(target_arch = "wasm32"))]