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

Do not read query in embedded web viewer #6515

Merged
merged 25 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ec560c9
wip
jprochazk Jun 7, 2024
e574ca5
update AppOptions type
jprochazk Jun 7, 2024
023c2ea
Merge branch 'main' into jan/remove-query-map
jprochazk Jun 11, 2024
750c84a
Merge branch 'main' into jan/remove-query-map
jprochazk Jun 18, 2024
d9e0a9b
wip
jprochazk Jun 18, 2024
cf83f3e
Merge branch 'main' into jan/remove-query-map
jprochazk Jun 24, 2024
b7de892
Merge branch 'main' into jan/remove-query-map
jprochazk Jun 25, 2024
1a8bafc
Merge branch 'main' into jan/remove-query-map
jprochazk Jun 26, 2024
7b67c74
refactor history api
jprochazk Jun 26, 2024
9e2c932
remove settings.json change
jprochazk Jul 1, 2024
62f8348
Merge branch 'main' into jan/remove-query-map
jprochazk Jul 1, 2024
69498b0
Merge branch 'main' into jan/remove-query-map
jprochazk Jul 2, 2024
0b9221e
Merge branch 'main' into jan/remove-query-map
jprochazk Jul 2, 2024
1adc95c
ignore generated files in lint
jprochazk Jul 2, 2024
0923c20
fix lints
jprochazk Jul 2, 2024
81f797d
improve popstate event behavior
jprochazk Jul 2, 2024
c557f02
Merge branch 'main' into jan/remove-query-map
jprochazk Jul 2, 2024
1eeea44
move history into its own file
jprochazk Jul 2, 2024
5d9d19f
add some comments
jprochazk Jul 2, 2024
e7b9050
rm dead code
jprochazk Jul 2, 2024
e3a6bc0
link to issue
jprochazk Jul 2, 2024
f2c89f3
use default + remove unwrap
jprochazk Jul 2, 2024
e4a1aec
comment about target
jprochazk Jul 2, 2024
c8e643a
Merge branch 'main' into jan/remove-query-map
jprochazk Jul 2, 2024
3749457
fix lints
jprochazk Jul 2, 2024
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
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,8 @@
},
"[yaml]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
},
// Uncomment the following option and restart rust-analyzer to get it to check code behind `cfg(target_arch=wasm32)`.
// Don't forget to put it in a comment again before committing.
// "rust-analyzer.cargo.target": "wasm32-unknown-unknown"
}
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5200,6 +5200,7 @@ dependencies = [
"image",
"itertools 0.13.0",
"js-sys",
"parking_lot",
"poll-promise",
"re_analytics",
"re_blueprint_tree",
Expand Down
2 changes: 2 additions & 0 deletions crates/re_viewer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ egui.workspace = true
ehttp.workspace = true
image = { workspace = true, default-features = false, features = ["png"] }
itertools = { workspace = true }
parking_lot.workspace = true
poll-promise = { workspace = true, features = ["web"] }
rfd.workspace = true
ron.workspace = true
Expand All @@ -121,6 +122,7 @@ wasm-bindgen.workspace = true
web-sys = { workspace = true, features = [
"History",
"Location",
"PopStateEvent",
"Storage",
"Url",
"UrlSearchParams",
Expand Down
37 changes: 34 additions & 3 deletions crates/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,22 @@ pub struct StartupOptions {

/// Default overrides for state of top/side/bottom panels.
pub panel_state_overrides: PanelStateOverrides,

/// Whether or not to enable usage of the `History` API on web.
///
/// It is disabled by default.
///
/// This should only be enabled when it is acceptable for `rerun`
/// to push its own entries into browser history.
///
/// That only makes sense if it has "taken over" a page, and is
/// the only thing on that page. If you are embedding multiple
/// viewers onto the same page, then it's better to turn this off.
///
/// We use browser history in a limited way to track the currently
/// open example recording, see [`crate::history`].
#[cfg(target_arch = "wasm32")]
pub enable_history: bool,
jprochazk marked this conversation as resolved.
Show resolved Hide resolved
}

impl Default for StartupOptions {
Expand Down Expand Up @@ -107,6 +123,9 @@ impl Default for StartupOptions {
fullscreen_options: Default::default(),

panel_state_overrides: Default::default(),

#[cfg(target_arch = "wasm32")]
enable_history: false,
}
}
}
Expand All @@ -127,6 +146,9 @@ pub struct App {
pub(crate) egui_ctx: egui::Context,
screenshotter: crate::screenshotter::Screenshotter,

#[cfg(target_arch = "wasm32")]
pub(crate) popstate_listener: Option<crate::history::PopstateListener>,

#[cfg(not(target_arch = "wasm32"))]
profiler: re_tracing::Profiler,

Expand Down Expand Up @@ -272,6 +294,9 @@ impl App {
egui_ctx,
screenshotter,

#[cfg(target_arch = "wasm32")]
popstate_listener: None,

#[cfg(not(target_arch = "wasm32"))]
profiler: Default::default(),

Expand Down Expand Up @@ -945,6 +970,11 @@ impl App {
if let Some(store_view) = store_context {
let entity_db = store_view.recording;

#[cfg(target_arch = "wasm32")]
let is_history_enabled = self.startup_options.enable_history;
#[cfg(not(target_arch = "wasm32"))]
let is_history_enabled = false;

self.state.show(
app_blueprint,
ui,
Expand All @@ -960,6 +990,7 @@ impl App {
hide: self.startup_options.hide_welcome_screen,
opacity: self.welcome_screen_opacity(egui_ctx),
},
is_history_enabled,
);
}
render_ctx.before_submit();
Expand Down Expand Up @@ -1462,18 +1493,18 @@ impl eframe::App for App {
}

#[cfg(target_arch = "wasm32")]
{
if self.startup_options.enable_history {
// Handle pressing the back/forward mouse buttons explicitly, since eframe catches those.
let back_pressed =
egui_ctx.input(|i| i.pointer.button_pressed(egui::PointerButton::Extra1));
let fwd_pressed =
egui_ctx.input(|i| i.pointer.button_pressed(egui::PointerButton::Extra2));

if back_pressed {
crate::web_tools::go_back();
crate::history::go_back();
}
if fwd_pressed {
crate::web_tools::go_forward();
crate::history::go_forward();
}
}

Expand Down
3 changes: 2 additions & 1 deletion crates/re_viewer/src/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ impl AppState {
rx: &ReceiveSet<LogMsg>,
command_sender: &CommandSender,
welcome_screen_state: &WelcomeScreenState,
is_history_enabled: bool,
) {
re_tracing::profile_function!();

Expand Down Expand Up @@ -417,7 +418,7 @@ impl AppState {
.frame(viewport_frame)
.show_inside(ui, |ui| {
if show_welcome {
welcome_screen.ui(ui, command_sender, welcome_screen_state);
welcome_screen.ui(ui, command_sender, welcome_screen_state, is_history_enabled);
} else {
viewport.viewport_ui(ui, &ctx, view_states);
}
Expand Down
Loading
Loading