Skip to content

Commit

Permalink
Added --viewer-mode flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
zrezke committed Jun 13, 2024
1 parent 5168462 commit 1efa416
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 27 deletions.
57 changes: 30 additions & 27 deletions crates/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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() {
Expand Down
6 changes: 6 additions & 0 deletions crates/rerun/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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()
};

Expand Down

0 comments on commit 1efa416

Please sign in to comment.