diff --git a/crates/egui_kittest/Cargo.toml b/crates/egui_kittest/Cargo.toml index 1a322273a..d32c65a35 100644 --- a/crates/egui_kittest/Cargo.toml +++ b/crates/egui_kittest/Cargo.toml @@ -29,11 +29,11 @@ snapshot = ["dep:dify", "dep:image", "dep:open", "dep:tempfile", "image/png"] ## Expose the [`inspector_api`] wire protocol used to talk to the external ## `kittest_inspector` binary. Pull this in if you're building a tool that consumes the ## same stream — the binary itself enables this transitively. -inspector_api = ["dep:egui_inspection", "egui_inspection/protocol", "egui/serde"] +inspector_api = ["dep:egui_inspection", "egui/serde"] ## Stream frames + accesskit tree to a `kittest_inspector` window for live debugging. ## Auto-launches when the `KITTEST_INSPECTOR` env var is truthy. -inspector = ["inspector_api", "dep:image"] +inspector = ["inspector_api", "egui_inspection/png", "dep:image", "image/png"] ## Allows testing eframe::App eframe = ["dep:eframe", "eframe/accesskit"] diff --git a/crates/egui_kittest/src/inspector.rs b/crates/egui_kittest/src/inspector.rs index 3f27141f1..1882743bd 100644 --- a/crates/egui_kittest/src/inspector.rs +++ b/crates/egui_kittest/src/inspector.rs @@ -396,14 +396,28 @@ impl Connection { return; } self.step = self.step.saturating_add(1); + let screenshot = image.and_then(|img| match egui_inspection::encode_png( + img.width(), + img.height(), + img.as_raw(), + ) { + Ok(png) => Some(FrameScreenshot { + width: img.width(), + height: img.height(), + png, + }), + Err(err) => { + #[expect(clippy::print_stderr)] + { + eprintln!("[kittest] PNG encode failed: {err}"); + } + None + } + }); let frame = Frame { step: self.step, pixels_per_point, - screenshot: image.map(|img| FrameScreenshot { - width: img.width(), - height: img.height(), - rgba: img.as_raw().clone(), - }), + screenshot, accesskit, source, };