Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rerun reset command #3145

Merged
merged 9 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 35 additions & 6 deletions crates/rerun/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use re_ws_comms::RerunServerPort;
struct Args {
// Note: arguments are sorted lexicographically for nicer `--help` message:
#[command(subcommand)]
commands: Option<Commands>,
command: Option<Command>,

/// What bind address IP to use.
#[clap(long, default_value = "0.0.0.0")]
Expand Down Expand Up @@ -152,7 +152,7 @@ struct Args {
}

#[derive(Debug, Clone, Subcommand)]
enum Commands {
enum Command {
/// Configure the behavior of our analytics.
#[cfg(feature = "analytics")]
#[command(subcommand)]
Expand All @@ -170,6 +170,12 @@ enum Commands {
#[clap(long, default_value_t = false)]
full_dump: bool,
},

/// Reset the memory of the Rerun Viewer.
///
/// Only run this if you're having trouble with the Viewer,
/// e.g. if it is crashing on startup.
Reset,
}

#[derive(Debug, Clone, Subcommand)]
Expand Down Expand Up @@ -271,12 +277,12 @@ where
re_log::info!("--strict mode: any warning or error will cause Rerun to panic.");
}

let res = if let Some(commands) = &args.commands {
match commands {
let res = if let Some(command) = &args.command {
match command {
#[cfg(feature = "analytics")]
Commands::Analytics(analytics) => run_analytics(analytics).map_err(Into::into),
Command::Analytics(analytics) => run_analytics(analytics).map_err(Into::into),

Commands::Compare {
Command::Compare {
path_to_rrd1,
path_to_rrd2,
full_dump,
Expand All @@ -285,6 +291,8 @@ where
let path_to_rrd2 = PathBuf::from(path_to_rrd2);
run_compare(&path_to_rrd1, &path_to_rrd2, *full_dump)
}

Command::Reset => reset_viewer(),
}
} else {
run_impl(build_info, call_source, args).await
Expand All @@ -293,6 +301,7 @@ where
match res {
// Clean success
Ok(_) => Ok(0),

// Clean failure -- known error AddrInUse
Err(err)
if err
Expand All @@ -304,6 +313,7 @@ where
re_log::warn!("{err}");
Ok(1)
}

// Unclean failure -- re-raise exception
Err(err) => Err(err),
}
Expand Down Expand Up @@ -650,6 +660,25 @@ fn parse_max_latency(max_latency: Option<&String>) -> f32 {
})
}

fn reset_viewer() -> anyhow::Result<()> {
if let Some(data_dir) = re_viewer::external::eframe::storage_dir(re_viewer::native::APP_ID) {
jprochazk marked this conversation as resolved.
Show resolved Hide resolved
// Note: `remove_dir_all` fails if the directory doesn't exist.
if data_dir.exists() {
if let Err(err) = std::fs::remove_dir_all(&data_dir) {
anyhow::bail!("Failed to remove {data_dir:?}: {err}");
} else {
eprintln!("Removed {data_dir:?}.");
Ok(())
}
} else {
eprintln!("Rerun state was already cleared.");
Ok(())
}
} else {
anyhow::bail!("Failed to figure out where Rerun stores its data.")
}
}

// ----------------------------------------------------------------------------

use re_log::external::log;
Expand Down
7 changes: 7 additions & 0 deletions docs/content/getting-started/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ On WSL2, in addition to the above packages for Linux, you also need to run:
[TODO(#1250)](https://github.com/rerun-io/rerun/issues/1250): Running with the wayland window manager
sometimes causes Rerun to crash. Try setting `WINIT_UNIX_BACKEND=x11` as a workaround.

## Startup issues
If Rerun is having trouble starting, you can try resetting its memory with:

```
rerun reset
```

## Graphics issues

[Wgpu](https://github.com/gfx-rs/wgpu) (the graphics API we use) maintains a list of
Expand Down