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

Support loading multiple recordings and/or blueprints in web-viewer #5548

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,13 @@ debug = true
# 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 = "bf7ffb982a6e8c0a40d0871c38bccacef9ee8efb" } # egui master 2024-03-15
eframe = { git = "https://github.com/emilk/egui.git", rev = "bf7ffb982a6e8c0a40d0871c38bccacef9ee8efb" } # egui master 2024-03-15
egui = { git = "https://github.com/emilk/egui.git", rev = "bf7ffb982a6e8c0a40d0871c38bccacef9ee8efb" } # egui master 2024-03-15
egui_extras = { git = "https://github.com/emilk/egui.git", rev = "bf7ffb982a6e8c0a40d0871c38bccacef9ee8efb" } # egui master 2024-03-15
egui_plot = { git = "https://github.com/emilk/egui.git", rev = "bf7ffb982a6e8c0a40d0871c38bccacef9ee8efb" } # egui master 2024-03-15
egui-wgpu = { git = "https://github.com/emilk/egui.git", rev = "bf7ffb982a6e8c0a40d0871c38bccacef9ee8efb" } # egui master 2024-03-15
emath = { git = "https://github.com/emilk/egui.git", rev = "bf7ffb982a6e8c0a40d0871c38bccacef9ee8efb" } # egui master 2024-03-15
ecolor = { git = "https://github.com/emilk/egui.git", rev = "820fa3c43a2d20e140bc4525e0a1405e7420bb66" } # egui master 2024-03-17
eframe = { git = "https://github.com/emilk/egui.git", rev = "820fa3c43a2d20e140bc4525e0a1405e7420bb66" } # egui master 2024-03-17
egui = { git = "https://github.com/emilk/egui.git", rev = "820fa3c43a2d20e140bc4525e0a1405e7420bb66" } # egui master 2024-03-17
egui_extras = { git = "https://github.com/emilk/egui.git", rev = "820fa3c43a2d20e140bc4525e0a1405e7420bb66" } # egui master 2024-03-17
egui_plot = { git = "https://github.com/emilk/egui.git", rev = "820fa3c43a2d20e140bc4525e0a1405e7420bb66" } # egui master 2024-03-17
egui-wgpu = { git = "https://github.com/emilk/egui.git", rev = "820fa3c43a2d20e140bc4525e0a1405e7420bb66" } # egui master 2024-03-17
emath = { git = "https://github.com/emilk/egui.git", rev = "820fa3c43a2d20e140bc4525e0a1405e7420bb66" } # egui master 2024-03-17

# Useful while developing:
# ecolor = { path = "../../egui/crates/ecolor" }
Expand Down
7 changes: 5 additions & 2 deletions crates/re_data_source/src/data_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use anyhow::Context as _;
#[derive(Debug, Clone)]
pub enum DataSource {
/// A remote RRD file, served over http.
///
/// Could be either an `.rrd` recording or a `.rbl` blueprint.
RrdHttpUrl(String),

/// A path to a local file.
Expand Down Expand Up @@ -86,7 +88,7 @@ impl DataSource {
DataSource::FilePath(file_source, path)
} else if uri.starts_with("http://")
|| uri.starts_with("https://")
|| (uri.starts_with("www.") && uri.ends_with(".rrd"))
|| (uri.starts_with("www.") && (uri.ends_with(".rrd") || uri.ends_with(".rbl")))
{
DataSource::RrdHttpUrl(uri)
} else if uri.starts_with("ws://") || uri.starts_with("wss://") {
Expand All @@ -95,7 +97,7 @@ impl DataSource {
// Now we are into heuristics territory:
} else if looks_like_a_file_path(&uri) {
DataSource::FilePath(file_source, path)
} else if uri.ends_with(".rrd") {
} else if uri.ends_with(".rrd") || uri.ends_with(".rbl") {
DataSource::RrdHttpUrl(uri)
} else {
// If this is sometyhing like `foo.com` we can't know what it is until we connect to it.
Expand Down Expand Up @@ -234,6 +236,7 @@ fn test_data_source_from_uri() {
"https://foo.zip",
"example.zip/foo.rrd",
"www.foo.zip/foo.rrd",
"www.foo.zip/blueprint.rbl",
];
let ws = ["ws://foo.zip", "wss://foo.zip", "127.0.0.1"];

Expand Down
1 change: 1 addition & 0 deletions crates/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ impl App {
}

pub fn set_examples_manifest_url(&mut self, url: String) {
re_log::info!("Using manifest_url={url:?}");
self.state
.set_examples_manifest_url(&self.re_ui.egui_ctx, url);
}
Expand Down
59 changes: 33 additions & 26 deletions crates/re_viewer/src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,22 +133,21 @@ fn create_app(

let query_map = &cc.integration_info.web_info.location.query_map;

let manifest_url = match &manifest_url {
Some(url) => Some(url.as_str()),
None => query_map.get("manifest_url").map(String::as_str),
};
if let Some(url) = manifest_url {
app.set_examples_manifest_url(url.into());
re_log::info!("Using manifest_url={url:?}");
if let Some(manifest_url) = manifest_url {
app.set_examples_manifest_url(manifest_url.into());
} else {
for url in query_map.get("manifest_url").into_iter().flatten() {
app.set_examples_manifest_url(url.clone());
}
}

let url = match &url {
Some(url) => Some(url.as_str()),
None => query_map.get("url").map(String::as_str),
};
if let Some(url) = url {
let rx = url_to_receiver(url, egui_ctx.clone());
app.add_receiver(rx);
app.add_receiver(url_to_receiver(url, egui_ctx));
} else {
// NOTE: we support passing in multiple urls to multiple different recorording, blueprints, etc
for url in query_map.get("url").into_iter().flatten() {
app.add_receiver(url_to_receiver(url, egui_ctx.clone()));
}
}

app
Expand Down Expand Up @@ -223,6 +222,8 @@ pub fn set_email(email: String) {

enum EndpointCategory {
/// Could be a local path (`/foo.rrd`) or a remote url (`http://foo.com/bar.rrd`).
///
/// Could be a link to either an `.rrd` recording or a `.rbl` blueprint.
HttpRrd(String),

/// A remote Rerun server.
Expand All @@ -233,7 +234,7 @@ enum EndpointCategory {
}

fn categorize_uri(uri: &str) -> EndpointCategory {
if uri.starts_with("http") || uri.ends_with(".rrd") {
if uri.starts_with("http") || uri.ends_with(".rrd") || uri.ends_with(".rbl") {
EndpointCategory::HttpRrd(uri.into())
} else if uri.starts_with("ws:") || uri.starts_with("wss:") {
EndpointCategory::WebSocket(uri.into())
Expand Down Expand Up @@ -261,21 +262,27 @@ fn get_persist_state(info: &eframe::IntegrationInfo) -> bool {

fn get_query_bool(info: &eframe::IntegrationInfo, key: &str, default: bool) -> bool {
let default_int = default as i32;
match info
.web_info
.location
.query_map
.get(key)
.map(String::as_str)
{
Some("0") => false,
Some("1") => true,
Some(other) => {

if let Some(values) = info.web_info.location.query_map.get(key) {
if values.len() == 1 {
match values[0].as_str() {
"0" => false,
"1" => true,
other => {
re_log::warn!(
"Unexpected value for '{key}' query: {other:?}. Expected either '0' or '1'. Defaulting to '{default_int}'."
);
default
}
}
} else {
re_log::warn!(
"Unexpected value for '{key}' query: {other:?}. Expected either '0' or '1'. Defaulting to '{default_int}'."
"Found {} values for '{key}' query. Expected one or none. Defaulting to '{default_int}'.",
values.len()
);
default
}
_ => default,
} else {
default
}
}