From f54141e6c5c6d6316a8cc659d2af805633203c21 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 16 Sep 2024 16:30:07 +0200 Subject: [PATCH 1/7] Update egui --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 12 ++++++------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bce11d2cb0b3..d5fe0b19c6df 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1777,7 +1777,7 @@ checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30" [[package]] name = "ecolor" version = "0.28.1" -source = "git+https://github.com/emilk/egui.git?rev=66076101e12eee01dec374285521b0bed4ecc40a#66076101e12eee01dec374285521b0bed4ecc40a" +source = "git+https://github.com/emilk/egui.git?rev=89da356b79f7c7e11ac225e0f7c81ff953169db6#89da356b79f7c7e11ac225e0f7c81ff953169db6" dependencies = [ "bytemuck", "emath", @@ -1787,7 +1787,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.28.1" -source = "git+https://github.com/emilk/egui.git?rev=66076101e12eee01dec374285521b0bed4ecc40a#66076101e12eee01dec374285521b0bed4ecc40a" +source = "git+https://github.com/emilk/egui.git?rev=89da356b79f7c7e11ac225e0f7c81ff953169db6#89da356b79f7c7e11ac225e0f7c81ff953169db6" dependencies = [ "ahash", "bytemuck", @@ -1824,7 +1824,7 @@ dependencies = [ [[package]] name = "egui" version = "0.28.1" -source = "git+https://github.com/emilk/egui.git?rev=66076101e12eee01dec374285521b0bed4ecc40a#66076101e12eee01dec374285521b0bed4ecc40a" +source = "git+https://github.com/emilk/egui.git?rev=89da356b79f7c7e11ac225e0f7c81ff953169db6#89da356b79f7c7e11ac225e0f7c81ff953169db6" dependencies = [ "accesskit", "ahash", @@ -1841,7 +1841,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.28.1" -source = "git+https://github.com/emilk/egui.git?rev=66076101e12eee01dec374285521b0bed4ecc40a#66076101e12eee01dec374285521b0bed4ecc40a" +source = "git+https://github.com/emilk/egui.git?rev=89da356b79f7c7e11ac225e0f7c81ff953169db6#89da356b79f7c7e11ac225e0f7c81ff953169db6" dependencies = [ "ahash", "bytemuck", @@ -1860,7 +1860,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.28.1" -source = "git+https://github.com/emilk/egui.git?rev=66076101e12eee01dec374285521b0bed4ecc40a#66076101e12eee01dec374285521b0bed4ecc40a" +source = "git+https://github.com/emilk/egui.git?rev=89da356b79f7c7e11ac225e0f7c81ff953169db6#89da356b79f7c7e11ac225e0f7c81ff953169db6" dependencies = [ "accesskit_winit", "ahash", @@ -1900,7 +1900,7 @@ dependencies = [ [[package]] name = "egui_extras" version = "0.28.1" -source = "git+https://github.com/emilk/egui.git?rev=66076101e12eee01dec374285521b0bed4ecc40a#66076101e12eee01dec374285521b0bed4ecc40a" +source = "git+https://github.com/emilk/egui.git?rev=89da356b79f7c7e11ac225e0f7c81ff953169db6#89da356b79f7c7e11ac225e0f7c81ff953169db6" dependencies = [ "ahash", "egui", @@ -1916,7 +1916,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.28.1" -source = "git+https://github.com/emilk/egui.git?rev=66076101e12eee01dec374285521b0bed4ecc40a#66076101e12eee01dec374285521b0bed4ecc40a" +source = "git+https://github.com/emilk/egui.git?rev=89da356b79f7c7e11ac225e0f7c81ff953169db6#89da356b79f7c7e11ac225e0f7c81ff953169db6" dependencies = [ "ahash", "bytemuck", @@ -1989,7 +1989,7 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "emath" version = "0.28.1" -source = "git+https://github.com/emilk/egui.git?rev=66076101e12eee01dec374285521b0bed4ecc40a#66076101e12eee01dec374285521b0bed4ecc40a" +source = "git+https://github.com/emilk/egui.git?rev=89da356b79f7c7e11ac225e0f7c81ff953169db6#89da356b79f7c7e11ac225e0f7c81ff953169db6" dependencies = [ "bytemuck", "serde", @@ -2090,7 +2090,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.28.1" -source = "git+https://github.com/emilk/egui.git?rev=66076101e12eee01dec374285521b0bed4ecc40a#66076101e12eee01dec374285521b0bed4ecc40a" +source = "git+https://github.com/emilk/egui.git?rev=89da356b79f7c7e11ac225e0f7c81ff953169db6#89da356b79f7c7e11ac225e0f7c81ff953169db6" dependencies = [ "ab_glyph", "ahash", @@ -2109,7 +2109,7 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.28.1" -source = "git+https://github.com/emilk/egui.git?rev=66076101e12eee01dec374285521b0bed4ecc40a#66076101e12eee01dec374285521b0bed4ecc40a" +source = "git+https://github.com/emilk/egui.git?rev=89da356b79f7c7e11ac225e0f7c81ff953169db6#89da356b79f7c7e11ac225e0f7c81ff953169db6" [[package]] name = "equivalent" diff --git a/Cargo.toml b/Cargo.toml index 66e2f4e619a3..95347bfefa09 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -514,12 +514,12 @@ missing_errors_doc = "allow" # As a last resport, patch with a commit to our own repository. # ALWAYS document what PR the commit hash is part of, or when it was merged into the upstream trunk. -ecolor = { git = "https://github.com/emilk/egui.git", rev = "66076101e12eee01dec374285521b0bed4ecc40a" } # egui master 2024-09-06 -eframe = { git = "https://github.com/emilk/egui.git", rev = "66076101e12eee01dec374285521b0bed4ecc40a" } # egui master 2024-09-06 -egui = { git = "https://github.com/emilk/egui.git", rev = "66076101e12eee01dec374285521b0bed4ecc40a" } # egui master 2024-09-06 -egui_extras = { git = "https://github.com/emilk/egui.git", rev = "66076101e12eee01dec374285521b0bed4ecc40a" } # egui master 2024-09-06 -egui-wgpu = { git = "https://github.com/emilk/egui.git", rev = "66076101e12eee01dec374285521b0bed4ecc40a" } # egui master 2024-09-06 -emath = { git = "https://github.com/emilk/egui.git", rev = "66076101e12eee01dec374285521b0bed4ecc40a" } # egui master 2024-09-06 +ecolor = { git = "https://github.com/emilk/egui.git", rev = "89da356b79f7c7e11ac225e0f7c81ff953169db6" } # egui master 2024-09-16 +eframe = { git = "https://github.com/emilk/egui.git", rev = "89da356b79f7c7e11ac225e0f7c81ff953169db6" } # egui master 2024-09-16 +egui = { git = "https://github.com/emilk/egui.git", rev = "89da356b79f7c7e11ac225e0f7c81ff953169db6" } # egui master 2024-09-16 +egui_extras = { git = "https://github.com/emilk/egui.git", rev = "89da356b79f7c7e11ac225e0f7c81ff953169db6" } # egui master 2024-09-16 +egui-wgpu = { git = "https://github.com/emilk/egui.git", rev = "89da356b79f7c7e11ac225e0f7c81ff953169db6" } # egui master 2024-09-16 +emath = { git = "https://github.com/emilk/egui.git", rev = "89da356b79f7c7e11ac225e0f7c81ff953169db6" } # egui master 2024-09-16 # Useful while developing: # ecolor = { path = "../../egui/crates/ecolor" } From faa0e9b422c21a12c51a124413bed959a63cb3c0 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 16 Sep 2024 12:24:07 +0200 Subject: [PATCH 2/7] Add test for ui wakeup --- Cargo.lock | 10 +++++ crates/viewer/re_viewer/src/app.rs | 2 + tests/rust/test_ui_wakeup/Cargo.toml | 20 +++++++++ tests/rust/test_ui_wakeup/src/main.rs | 63 +++++++++++++++++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 tests/rust/test_ui_wakeup/Cargo.toml create mode 100644 tests/rust/test_ui_wakeup/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index d5fe0b19c6df..c7b01e040aa9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7107,6 +7107,16 @@ dependencies = [ "rerun", ] +[[package]] +name = "test_ui_wakeup" +version = "0.19.0-alpha.1+dev" +dependencies = [ + "anyhow", + "clap", + "re_log", + "rerun", +] + [[package]] name = "thiserror" version = "1.0.63" diff --git a/crates/viewer/re_viewer/src/app.rs b/crates/viewer/re_viewer/src/app.rs index fae36b6cf3d9..9702e09a408c 100644 --- a/crates/viewer/re_viewer/src/app.rs +++ b/crates/viewer/re_viewer/src/app.rs @@ -1034,6 +1034,8 @@ impl App { let start = web_time::Instant::now(); while let Some((channel_source, msg)) = self.rx.try_recv() { + re_log::trace!("Received a message from {channel_source:?}"); // Used by `test_ui_wakeup` test app! + let msg = match msg.payload { re_smart_channel::SmartMessagePayload::Msg(msg) => msg, diff --git a/tests/rust/test_ui_wakeup/Cargo.toml b/tests/rust/test_ui_wakeup/Cargo.toml new file mode 100644 index 000000000000..b70252ac2f0b --- /dev/null +++ b/tests/rust/test_ui_wakeup/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "test_ui_wakeup" +version.workspace = true +edition.workspace = true +rust-version.workspace = true +license.workspace = true +publish = false + +[lints] +workspace = true + +[dependencies] +re_log = { workspace = true, features = ["setup"] } +rerun = { path = "../../../crates/top/rerun", features = [ + "clap", + "web_viewer", +] } + +anyhow.workspace = true +clap = { workspace = true, features = ["derive"] } diff --git a/tests/rust/test_ui_wakeup/src/main.rs b/tests/rust/test_ui_wakeup/src/main.rs new file mode 100644 index 000000000000..605d3d4fef17 --- /dev/null +++ b/tests/rust/test_ui_wakeup/src/main.rs @@ -0,0 +1,63 @@ +//! Test that the Rerun Viewer UI wakes up as new messages arrive, +//! even if the viewer is hidden. +//! +//! ## Test setup - build the viewer +//! * `pixi run rerun-build` +//! * `pixi run rerun-build-web` +//! +//! ## Test matrix +//! * Run `cargo r -p test_ui_wakeup` and test: +//! * That the viewer wakes up in the background when it's alt-tabbed +//! * That the viewer wakes up when minimized (it should log "Received a message from…") +//! * Run `cargo r -p test_ui_wakeup -- --serve` and test: +//! * The viewer wakes up when browser is alt-tabbed away +//! * Switch to a different browser tab, send a few messages, switch back. The messages should be there +//! (this is not a conclusive test, as the messages might have been received on tab select) + +use std::io::Read as _; + +#[derive(Debug, clap::Parser)] +#[clap(author, version, about)] +struct Args { + #[command(flatten)] + rerun: rerun::clap::RerunArgs, +} + +fn main() -> anyhow::Result<()> { + re_log::setup_logging(); + + use clap::Parser as _; + let args = Args::parse(); + + // This is so that re_viewer logs incoming messages: + let rust_log = "info,re_viewer=trace"; + eprintln!("Setting RUST_LOG={rust_log}"); + std::env::set_var("RUST_LOG", rust_log); + + println!("Starting Viewer…"); + let (rec, _serve_guard) = args.rerun.init("rerun_example_ui_wakeup")?; + + // Wait out some log spam from the viewer starting: + std::thread::sleep(std::time::Duration::from_secs(1)); + + println!("Now put the viewer in the background (alt-tab, minimize, put in background tab, etc"); + + for i in 0..usize::MAX { + println!("Sending message number {i}…"); + rec.log( + "Text", + &rerun::TextDocument::new(format!("This is message number {i}")), + )?; + println!("Press ENTER to send more data to the viewer"); + + wait_from_enter(); + } + + Ok(()) +} + +fn wait_from_enter() { + let _ = std::io::stdin() + .read(&mut [0u8]) + .expect("Failed to read from stdin"); +} From 7107e67d95091818cea4ebdeb0592a6f5b40b5d2 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 16 Sep 2024 17:12:54 +0200 Subject: [PATCH 3/7] Improve instructions --- tests/rust/test_ui_wakeup/src/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/rust/test_ui_wakeup/src/main.rs b/tests/rust/test_ui_wakeup/src/main.rs index 605d3d4fef17..4efae636b725 100644 --- a/tests/rust/test_ui_wakeup/src/main.rs +++ b/tests/rust/test_ui_wakeup/src/main.rs @@ -4,6 +4,7 @@ //! ## Test setup - build the viewer //! * `pixi run rerun-build` //! * `pixi run rerun-build-web` +//! * Make sure `target/debug` is in your `PATH` //! //! ## Test matrix //! * Run `cargo r -p test_ui_wakeup` and test: From 61cd33224f6be869c3c611d5f31589ce355b605e Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 16 Sep 2024 17:17:38 +0200 Subject: [PATCH 4/7] Add instructions to `BUILD.rs` to add `target/debug` to PATH --- BUILD.md | 2 +- tests/rust/test_ui_wakeup/src/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD.md b/BUILD.md index c0bc6e0745d5..405d42543bd7 100644 --- a/BUILD.md +++ b/BUILD.md @@ -39,7 +39,7 @@ Use this command for building and running the viewer: pixi run rerun ``` -This custom cargo command is enabled by an alias located in `.cargo/config.toml`. +It is recommended you add `target/debug` to the start of your `PATH`. That way, all examples that call `spawn` will use your latest built `rerun` binary. ## Running the Rust examples diff --git a/tests/rust/test_ui_wakeup/src/main.rs b/tests/rust/test_ui_wakeup/src/main.rs index 4efae636b725..62f8c54b9ee1 100644 --- a/tests/rust/test_ui_wakeup/src/main.rs +++ b/tests/rust/test_ui_wakeup/src/main.rs @@ -4,7 +4,7 @@ //! ## Test setup - build the viewer //! * `pixi run rerun-build` //! * `pixi run rerun-build-web` -//! * Make sure `target/debug` is in your `PATH` +//! * Make sure `target/debug` is at the start of your `PATH` //! //! ## Test matrix //! * Run `cargo r -p test_ui_wakeup` and test: From 2dac16f75a36a00a59384d1e2651115711199288 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 18 Sep 2024 09:17:26 +0200 Subject: [PATCH 5/7] =?UTF-8?q?No=20need=20to=20end=20the=20range=E2=80=A6?= =?UTF-8?q?=20maybe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Antoine Beyeler <49431240+abey79@users.noreply.github.com> --- tests/rust/test_ui_wakeup/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/rust/test_ui_wakeup/src/main.rs b/tests/rust/test_ui_wakeup/src/main.rs index 62f8c54b9ee1..a9e323b87441 100644 --- a/tests/rust/test_ui_wakeup/src/main.rs +++ b/tests/rust/test_ui_wakeup/src/main.rs @@ -43,7 +43,7 @@ fn main() -> anyhow::Result<()> { println!("Now put the viewer in the background (alt-tab, minimize, put in background tab, etc"); - for i in 0..usize::MAX { + for i in 0.. { println!("Sending message number {i}…"); rec.log( "Text", From 3a2c5f4d4b628f48d7f39d8b8847e0f7eb302397 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 18 Sep 2024 10:37:16 +0200 Subject: [PATCH 6/7] Remove instructions about putting target/debug on PATH --- BUILD.md | 2 -- tests/rust/test_ui_wakeup/src/main.rs | 1 - 2 files changed, 3 deletions(-) diff --git a/BUILD.md b/BUILD.md index c548fb919c7f..710dda1a4df9 100644 --- a/BUILD.md +++ b/BUILD.md @@ -39,8 +39,6 @@ Use this command for building and running the viewer: pixi run rerun ``` -It is recommended you add `target/debug` to the start of your `PATH`. That way, all examples that call `spawn` will use your latest built `rerun` binary. - ## Running the Rust examples diff --git a/tests/rust/test_ui_wakeup/src/main.rs b/tests/rust/test_ui_wakeup/src/main.rs index a9e323b87441..e3a97cf5e0b4 100644 --- a/tests/rust/test_ui_wakeup/src/main.rs +++ b/tests/rust/test_ui_wakeup/src/main.rs @@ -4,7 +4,6 @@ //! ## Test setup - build the viewer //! * `pixi run rerun-build` //! * `pixi run rerun-build-web` -//! * Make sure `target/debug` is at the start of your `PATH` //! //! ## Test matrix //! * Run `cargo r -p test_ui_wakeup` and test: From c4a95f20fb43c9387f5c1ff61067f7d40031bc36 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Wed, 18 Sep 2024 10:38:01 +0200 Subject: [PATCH 7/7] Revert BUILD.md --- BUILD.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/BUILD.md b/BUILD.md index 710dda1a4df9..5a20261dd126 100644 --- a/BUILD.md +++ b/BUILD.md @@ -39,6 +39,8 @@ Use this command for building and running the viewer: pixi run rerun ``` +This custom cargo command is enabled by an alias located in `.cargo/config.toml`. + ## Running the Rust examples