Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix(cua-driver): start the composited X11 overlay test's reads once its desktop is on screen (#6512)

injaneity566a4ce65590
diff --git a/libs/cua-driver/rust/crates/platform-linux/src/overlay.rs b/libs/cua-driver/rust/crates/platform-linux/src/overlay.rs
index deabb96df4..e6ed28556f 100644
--- a/libs/cua-driver/rust/crates/platform-linux/src/overlay.rs
+++ b/libs/cua-driver/rust/crates/platform-linux/src/overlay.rs
@@ -4371,6 +4371,25 @@ mod tests {
drawn: std::cell::RefCell::new(Vec::new()),
};
conn.sync()?;
+ // A compositing manager shows a newly mapped window only once it has
+ // painted it. Until then the root shows through, and picom 12.5 paints
+ // a root with no wallpaper black, so the first read can be all black
+ // before the overlay has drawn anything. Start reading once the white
+ // desktop is on screen, so every read is of the overlay's frames.
+ let deadline = Instant::now() + Duration::from_secs(3);
+ while conn
+ .get_image(ImageFormat::Z_PIXMAP, root, 0, 0, AREA, AREA, !0)?
+ .reply()?
+ .data
+ .chunks_exact(4)
+ .any(|px| px[..3] != [255, 255, 255])
+ {
+ anyhow::ensure!(
+ Instant::now() < deadline,
+ "the white desktop never came on screen"
+ );
+ std::thread::sleep(Duration::from_millis(5));
+ }
let done = Arc::new(AtomicBool::new(false));
let reads = Arc::new(AtomicUsize::new(0));