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

Update to latest egui, with added error handling in eframe #537

Merged
merged 1 commit into from
Dec 12, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 12 additions & 19 deletions Cargo.lock

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

16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ opt-level = 2
debug = true

[patch.crates-io]
# # 2022-12-08 - egui style tweaks
# ecolor = { git = "https://github.com/emilk/egui", rev = "da0a1787019cb28c26e969bc537a191f2ed302f3" }
# eframe = { git = "https://github.com/emilk/egui", rev = "da0a1787019cb28c26e969bc537a191f2ed302f3" }
# egui = { git = "https://github.com/emilk/egui", rev = "da0a1787019cb28c26e969bc537a191f2ed302f3" }
# egui_extras = { git = "https://github.com/emilk/egui", rev = "da0a1787019cb28c26e969bc537a191f2ed302f3" }
# egui-wgpu = { git = "https://github.com/emilk/egui", rev = "da0a1787019cb28c26e969bc537a191f2ed302f3" }
# emath = { git = "https://github.com/emilk/egui", rev = "da0a1787019cb28c26e969bc537a191f2ed302f3" }
# epaint = { git = "https://github.com/emilk/egui", rev = "da0a1787019cb28c26e969bc537a191f2ed302f3" }
# # 2022-12-12 - eframe::run_return can return an error
ecolor = { git = "https://github.com/emilk/egui", rev = "e0b5bb17e5851fb5a6904847e353aa74db3441bb" }
eframe = { git = "https://github.com/emilk/egui", rev = "e0b5bb17e5851fb5a6904847e353aa74db3441bb" }
egui = { git = "https://github.com/emilk/egui", rev = "e0b5bb17e5851fb5a6904847e353aa74db3441bb" }
egui_extras = { git = "https://github.com/emilk/egui", rev = "e0b5bb17e5851fb5a6904847e353aa74db3441bb" }
egui-wgpu = { git = "https://github.com/emilk/egui", rev = "e0b5bb17e5851fb5a6904847e353aa74db3441bb" }
emath = { git = "https://github.com/emilk/egui", rev = "e0b5bb17e5851fb5a6904847e353aa74db3441bb" }
epaint = { git = "https://github.com/emilk/egui", rev = "e0b5bb17e5851fb5a6904847e353aa74db3441bb" }

# ecolor = { path = "../../egui/crates/ecolor" }
# eframe = { path = "../../egui/crates/eframe" }
Expand Down
4 changes: 2 additions & 2 deletions crates/re_ui/examples/re_ui_example.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
fn main() {
fn main() -> eframe::Result<()> {
let native_options = eframe::NativeOptions {
initial_window_size: Some([1200.0, 800.0].into()),
follow_system_theme: false,
Expand All @@ -23,7 +23,7 @@ fn main() {
bottom_panel: true,
})
}),
);
)
}

pub struct ExampleApp {
Expand Down
8 changes: 4 additions & 4 deletions crates/re_viewer/src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use re_log_types::LogMsg;
type AppCreator =
Box<dyn FnOnce(&eframe::CreationContext<'_>, re_ui::ReUi) -> Box<dyn eframe::App>>;

pub fn run_native_app(app_creator: AppCreator) {
pub fn run_native_app(app_creator: AppCreator) -> eframe::Result<()> {
let native_options = eframe::NativeOptions {
depth_buffer: 0,
multisampling: 0, // the 3D views do their own MSAA
Expand All @@ -29,13 +29,13 @@ pub fn run_native_app(app_creator: AppCreator) {
let re_ui = crate::customize_eframe(cc);
app_creator(cc, re_ui)
}),
);
)
}

pub fn run_native_viewer_with_messages(
startup_options: crate::StartupOptions,
log_messages: Vec<LogMsg>,
) {
) -> eframe::Result<()> {
let (tx, rx) = re_smart_channel::smart_channel(re_smart_channel::Source::File);
for log_msg in log_messages {
tx.send(log_msg).ok();
Expand All @@ -47,5 +47,5 @@ pub fn run_native_viewer_with_messages(
cc.storage,
rx,
))
}));
}))
}
4 changes: 2 additions & 2 deletions crates/rerun/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ async fn run_impl(args: Args) -> anyhow::Result<()> {
let mut app = re_viewer::App::from_receiver(startup_options, re_ui, cc.storage, rx);
app.set_profiler(profiler);
Box::new(app)
}));
}))?;
}
Ok(())
}
Expand Down Expand Up @@ -180,7 +180,7 @@ async fn connect_to_ws_url(
);
app.set_profiler(profiler);
Box::new(app)
}));
}))?;
}
Ok(())
}
Expand Down
4 changes: 3 additions & 1 deletion crates/rerun_sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ publish = false
default = ["re_viewer"]

## Support for the viewer
re_viewer = ["dep:re_viewer"]
re_viewer = ["dep:re_viewer", "dep:eframe"]

## Support serving a web viewer over HTTP.
##
Expand Down Expand Up @@ -41,6 +41,8 @@ re_viewer = { path = "../re_viewer", features = [
"puffin",
], default-features = false, optional = true }
re_web_server = { path = "../re_web_server", optional = true }

eframe = { verison = "0.20", default-features = false, optional = true }
webbrowser = { version = "0.8", optional = true }

# Native dependencies:
Expand Down
5 changes: 4 additions & 1 deletion crates/rerun_sdk/examples/log_rects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ fn main() -> std::process::ExitCode {
session.flush();
} else {
let log_messages = session.drain_log_messages_buffer();
rerun_sdk::viewer::show(log_messages);
if let Err(err) = rerun_sdk::viewer::show(log_messages) {
eprintln!("Failed to start viewer: {err}");
return std::process::ExitCode::FAILURE;
}
}

std::process::ExitCode::SUCCESS
Expand Down
4 changes: 2 additions & 2 deletions crates/rerun_sdk/src/viewer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use re_log_types::LogMsg;

#[cfg(feature = "re_viewer")]
pub fn show(log_messages: Vec<LogMsg>) {
pub fn show(log_messages: Vec<LogMsg>) -> eframe::Result<()> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a bit surprised to see an eframe::Result leak out of the SDK. Seems like we should potentially be introducing a rerun_sdk error type.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I was a bit hesitant here too. We should probably wrap it in our own type, but this is an ok start imho

let startup_options = re_viewer::StartupOptions::default();
re_viewer::run_native_viewer_with_messages(startup_options, log_messages);
re_viewer::run_native_viewer_with_messages(startup_options, log_messages)
}
6 changes: 3 additions & 3 deletions rerun_py/src/python_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,11 @@ fn show() -> PyResult<()> {

if log_messages.is_empty() {
re_log::info!("Nothing logged, so nothing to show");
Ok(())
} else {
rerun_sdk::viewer::show(log_messages);
rerun_sdk::viewer::show(log_messages)
.map_err(|err| PyRuntimeError::new_err(format!("Failed to show Rerun Viewer: {err}")))
}

Ok(())
}

#[pyfunction]
Expand Down