From 1efa416875e1026250817289732b15c1b372fd8b Mon Sep 17 00:00:00 2001 From: zrezke Date: Thu, 13 Jun 2024 18:25:33 +0200 Subject: [PATCH] Added --viewer-mode flag. --- crates/re_viewer/src/app.rs | 57 +++++++++++++++++++------------------ crates/rerun/src/run.rs | 6 ++++ 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/crates/re_viewer/src/app.rs b/crates/re_viewer/src/app.rs index 7616b577ab9e..e6c68f8cc484 100644 --- a/crates/re_viewer/src/app.rs +++ b/crates/re_viewer/src/app.rs @@ -51,6 +51,7 @@ pub struct StartupOptions { pub memory_limit: re_memory::MemoryLimit, pub persist_state: bool, pub sdk_port: u32, + pub viewer_mode: bool, } #[derive(Clone, Default)] @@ -571,37 +572,39 @@ impl eframe::App for App { } dependency_installer.update(); } - match &mut self.backend_handle { - Some((handle, port)) => match handle.try_wait() { - Ok(status) => { - match status { - Some(_) => { - let _ = handle.kill(); // It will only Err in case the process is already dead (which is what we want anyway) - self.state.depthai_state.reset(); - re_log::debug!("Backend process has exited, restarting!"); - self.backend_handle = self.spawn_backend(&self.backend_environment); - } - None => { - if !self.state.depthai_state.backend_comms.ws.is_initialized() { - self.state.depthai_state.backend_comms.ws.connect(*port); + if !self.startup_options.viewer_mode { + match &mut self.backend_handle { + Some((handle, port)) => match handle.try_wait() { + Ok(status) => { + match status { + Some(_) => { + let _ = handle.kill(); // It will only Err in case the process is already dead (which is what we want anyway) + self.state.depthai_state.reset(); + re_log::debug!("Backend process has exited, restarting!"); + self.backend_handle = self.spawn_backend(&self.backend_environment); + } + None => { + if !self.state.depthai_state.backend_comms.ws.is_initialized() { + self.state.depthai_state.backend_comms.ws.connect(*port); + } } } } + Err(_) => { + } + }, + None => { + if self.backend_environment.are_requirements_installed() { + self.backend_handle = self.spawn_backend(&self.backend_environment); + } else { + re_log::debug!( + "Backend requirements not installed, starting dependency installer!" + ); + self.install_dependencies(); + } } - Err(_) => { - } - }, - None => { - if self.backend_environment.are_requirements_installed() { - self.backend_handle = self.spawn_backend(&self.backend_environment); - } else { - re_log::debug!( - "Backend requirements not installed, starting dependency installer!" - ); - self.install_dependencies(); - } - } - }; + }; + } } if self.startup_options.memory_limit.limit.is_none() { diff --git a/crates/rerun/src/run.rs b/crates/rerun/src/run.rs index 86ec67d4d5ac..b428e27464f9 100644 --- a/crates/rerun/src/run.rs +++ b/crates/rerun/src/run.rs @@ -121,6 +121,11 @@ struct Args { #[cfg(feature = "web_viewer")] #[clap(long, default_value_t = Default::default())] ws_server_port: RerunServerPort, + + /// Start the viewer in viewer mode. (No demo will try to run. This is close to being stock rerun.) + #[cfg(feature = "native_viewer")] + #[clap(long, default_value_t = Default::default())] + viewer_mode: bool, } #[derive(Debug, Clone, Subcommand)] @@ -297,6 +302,7 @@ async fn run_impl( #[cfg(feature = "native_viewer")] let startup_options = re_viewer::StartupOptions { persist_state: args.persist_state, + viewer_mode: args.viewer_mode, ..Default::default() };