diff --git a/Cargo.lock b/Cargo.lock index 11300dc..a6bec4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -278,6 +278,7 @@ dependencies = [ "iroh", "iroh-relay", "libc", + "libloading 0.8.9", "minifb", "mp4", "objc2", diff --git a/crates/net/tests/tunnel.rs b/crates/net/tests/tunnel.rs index 8f46d03..7f99113 100644 --- a/crates/net/tests/tunnel.rs +++ b/crates/net/tests/tunnel.rs @@ -440,9 +440,13 @@ async fn without_an_answer_to_the_probes_the_relay_still_makes_it_type_2() { assert!(!reach.udp, "{reach:?}"); assert!(side.tunnels.relay_connected()); assert_eq!(tunnel::nat_type(Some(&reach), true), 2); - // The relay goes away: nothing answers any more. + // The relay goes away: nothing answers any more. A relay that closes its connection says + // so at once (about 60 ms on an idle machine). When that close does not reach the endpoint + // (the server is torn down while it is being sent, which a loaded macOS runner does + // sometimes), the endpoint finds out from its QUIC connection, which gives up after the + // relay client's idle timeout of 35 s (iroh-relay, quic.rs). Wait for that, not for 10 s. relay.stop().await; - let gone = tokio::time::timeout(Duration::from_secs(10), async { + let gone = tokio::time::timeout(Duration::from_secs(45), async { while side.tunnels.relay_connected() { tokio::time::sleep(Duration::from_millis(50)).await; } diff --git a/crates/share-worker/tests/access.rs b/crates/share-worker/tests/access.rs index 8f8627a..72a8d1b 100644 --- a/crates/share-worker/tests/access.rs +++ b/crates/share-worker/tests/access.rs @@ -178,7 +178,7 @@ mod real_window { use std::time::{Duration, Instant}; use anyplay_share_worker::capture::{self, WindowTarget}; - use anyplay_share_worker::mac::sck::SckSound; + use anyplay_share_worker::mac::sck::{self, SckSound}; use anyplay_share_worker::sound::SoundSource; use super::{WORKER, screen_access}; @@ -228,8 +228,21 @@ mod real_window { let deadline = Instant::now() + Duration::from_secs(20); while Instant::now() < deadline { if let Some(pid) = pid_of_calculator() { - // The window needs a moment to be drawn. - std::thread::sleep(Duration::from_secs(3)); + // The window is drawn some time after the process exists: on a cold start of + // a loaded runner longer than the few seconds the worker looks for it. Wait + // until the system lists it (each try looks for a few seconds itself). + let target = WindowTarget { + window: None, + pids: vec![pid], + title_contains: String::new(), + }; + let listed_by = Instant::now() + Duration::from_secs(60); + while sck::find_window(&target).is_err() { + assert!( + Instant::now() < listed_by, + "Calculator has no window after 60 s" + ); + } return Some(Calculator { pid, started_here,