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 egui with deadlock fix #911

Merged
merged 3 commits into from
Jan 25, 2023
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
28 changes: 13 additions & 15 deletions Cargo.lock

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

25 changes: 15 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,14 @@ arrow2_convert = { git = "https://github.com/rerun-io/arrow2-convert", rev = "7e
# arrow2 = { path = "../arrow2" }
# arrow2_convert = { path = "../arrow2-convert/arrow2_convert" }

# 2022-01-24: allow hiding button backgrounds
ecolor = { git = "https://github.com/emilk/egui", rev = "eee4cf6a824e21141bb893aae2aea7849c0e9e03" }
eframe = { git = "https://github.com/emilk/egui", rev = "eee4cf6a824e21141bb893aae2aea7849c0e9e03" }
egui = { git = "https://github.com/emilk/egui", rev = "eee4cf6a824e21141bb893aae2aea7849c0e9e03" }
egui_extras = { git = "https://github.com/emilk/egui", rev = "eee4cf6a824e21141bb893aae2aea7849c0e9e03" }
egui-wgpu = { git = "https://github.com/emilk/egui", rev = "eee4cf6a824e21141bb893aae2aea7849c0e9e03" }
emath = { git = "https://github.com/emilk/egui", rev = "eee4cf6a824e21141bb893aae2aea7849c0e9e03" }
epaint = { git = "https://github.com/emilk/egui", rev = "eee4cf6a824e21141bb893aae2aea7849c0e9e03" }

# 2023-01-25 - egui deadlock fix
ecolor = { git = "https://github.com/emilk/egui", rev = "8ce0e1c5206780e76234842b94ceb0edf5bb8b75" }
eframe = { git = "https://github.com/emilk/egui", rev = "8ce0e1c5206780e76234842b94ceb0edf5bb8b75" }
egui = { git = "https://github.com/emilk/egui", rev = "8ce0e1c5206780e76234842b94ceb0edf5bb8b75" }
egui_extras = { git = "https://github.com/emilk/egui", rev = "8ce0e1c5206780e76234842b94ceb0edf5bb8b75" }
egui-wgpu = { git = "https://github.com/emilk/egui", rev = "8ce0e1c5206780e76234842b94ceb0edf5bb8b75" }
emath = { git = "https://github.com/emilk/egui", rev = "8ce0e1c5206780e76234842b94ceb0edf5bb8b75" }
epaint = { git = "https://github.com/emilk/egui", rev = "8ce0e1c5206780e76234842b94ceb0edf5bb8b75" }
# ecolor = { path = "../../egui/crates/ecolor" }
# eframe = { path = "../../egui/crates/eframe" }
# egui = { path = "../../egui/crates/egui" }
Expand All @@ -84,7 +83,13 @@ epaint = { git = "https://github.com/emilk/egui", rev = "eee4cf6a824e21141bb893a
# emath = { path = "../../egui/crates/emath" }
# epaint = { path = "../../egui/crates/epaint" }

# 2022-10-12 - Alpha to coverage support for GLES
# Forks of 3rd party egui crates, tracking latest egui/master:
egui_dock = { git = "https://github.com/rerun-io/egui_dock", rev = "1355a9f24e99518ef7b9546872a0f25ffe1f91d2" } # https://github.com/Adanos020/egui_dock/pull/93
egui-notify = { git = "https://github.com/rerun-io/egui-notify", rev = "a158c2b81ca69ac78e3c61a705f478e8af76fd7d" } # https://github.com/ItsEthra/egui-notify/pull/10
# egui_dock = { path = "../../forks/egui_dock" }
# egui-notify = { path = "../../forks/egui-notify" }

# 2023-10-12 - Alpha to coverage support for GLES
wgpu = { git = "https://github.com/gfx-rs/wgpu.git", ref = "a377ae2b7fe6c1c9412751166f0917e617164e49" }
wgpu-core = { git = "https://github.com/gfx-rs/wgpu.git", ref = "a377ae2b7fe6c1c9412751166f0917e617164e49" }
# wgpu = { path = "../wgpu/wgpu" }
17 changes: 9 additions & 8 deletions crates/re_ui/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,20 +167,21 @@ impl Command {
pub fn listen_for_kb_shortcut(egui_ctx: &egui::Context) -> Option<Command> {
use strum::IntoEnumIterator as _;

let anything_has_focus = egui_ctx.memory().focus().is_some();
let anything_has_focus = egui_ctx.memory(|mem| mem.focus().is_some());
if anything_has_focus {
return None; // e.g. we're typing in a TextField
}

let mut input = egui_ctx.input_mut();
for command in Command::iter() {
if let Some(kb_shortcut) = command.kb_shortcut() {
if input.consume_shortcut(&kb_shortcut) {
return Some(command);
egui_ctx.input_mut(|input| {
for command in Command::iter() {
if let Some(kb_shortcut) = command.kb_shortcut() {
if input.consume_shortcut(&kb_shortcut) {
return Some(command);
}
}
}
}
None
None
})
}

/// Show this command as a menu-button.
Expand Down
18 changes: 7 additions & 11 deletions crates/re_ui/src/command_palette.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ impl CommandPalette {
/// Show the command palette, if it is visible.
#[must_use = "Returns the command that was selected"]
pub fn show(&mut self, egui_ctx: &egui::Context) -> Option<Command> {
self.visible &= !egui_ctx
.input_mut()
.consume_key(Default::default(), Key::Escape);
self.visible &= !egui_ctx.input_mut(|i| i.consume_key(Default::default(), Key::Escape));
if !self.visible {
self.query.clear();
return None;
}

let screen_rect = egui_ctx.input().screen_rect();
let screen_rect = egui_ctx.screen_rect();
let width = 300.0;
let max_height = 320.0.at_most(screen_rect.height());

Expand All @@ -43,7 +41,7 @@ impl CommandPalette {
#[must_use = "Returns the command that was selected"]
fn window_content_ui(&mut self, ui: &mut egui::Ui) -> Option<Command> {
// Check _before_ we add the `TextEdit`, so it doesn't steal it.
let enter_pressed = ui.input_mut().consume_key(Default::default(), Key::Enter);
let enter_pressed = ui.input_mut(|i| i.consume_key(Default::default(), Key::Enter));

let text_response = ui.add(
egui::TextEdit::singleline(&mut self.query)
Expand Down Expand Up @@ -78,8 +76,8 @@ impl CommandPalette {
enter_pressed: bool,
mut scroll_to_selected_alternative: bool,
) -> Option<Command> {
scroll_to_selected_alternative |= ui.input().key_pressed(Key::ArrowUp);
scroll_to_selected_alternative |= ui.input().key_pressed(Key::ArrowDown);
scroll_to_selected_alternative |= ui.input(|i| i.key_pressed(Key::ArrowUp));
scroll_to_selected_alternative |= ui.input(|i| i.key_pressed(Key::ArrowDown));

let query = self.query.to_lowercase();

Expand Down Expand Up @@ -159,12 +157,10 @@ impl CommandPalette {

// Move up/down in the list:
self.selected_alternative = self.selected_alternative.saturating_sub(
ui.input_mut()
.count_and_consume_key(Default::default(), Key::ArrowUp),
ui.input_mut(|i| i.count_and_consume_key(Default::default(), Key::ArrowUp)),
);
self.selected_alternative = self.selected_alternative.saturating_add(
ui.input_mut()
.count_and_consume_key(Default::default(), Key::ArrowDown),
ui.input_mut(|i| i.count_and_consume_key(Default::default(), Key::ArrowDown)),
);

self.selected_alternative = self
Expand Down
2 changes: 1 addition & 1 deletion crates/re_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl ReUi {
/// Paint a watermark
pub fn paint_watermark(&self) {
let logo = self.rerun_logo();
let screen_rect = self.egui_ctx.input().screen_rect;
let screen_rect = self.egui_ctx.screen_rect();
let size = logo.size_vec2();
let rect = Align2::RIGHT_BOTTOM
.align_size_within_rect(size, screen_rect)
Expand Down
30 changes: 17 additions & 13 deletions crates/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,10 @@ impl eframe::App for App {

self.run_pending_commands(egui_ctx, frame);

self.frame_time_history
.add(egui_ctx.input().time, frame_start.elapsed().as_secs_f32());
self.frame_time_history.add(
egui_ctx.input(|i| i.time),
frame_start.elapsed().as_secs_f32(),
);
}
}

Expand Down Expand Up @@ -667,7 +669,7 @@ impl App {

// Keep the style:
let style = egui_ctx.style();
*egui_ctx.memory() = Default::default();
egui_ctx.memory_mut(|mem| *mem = Default::default());
egui_ctx.set_style((*style).clone());
}

Expand All @@ -684,13 +686,13 @@ impl App {
preview_files_being_dropped(egui_ctx);

// Collect dropped files:
if egui_ctx.input().raw.dropped_files.len() > 2 {
if egui_ctx.input(|i| i.raw.dropped_files.len()) > 2 {
rfd::MessageDialog::new()
.set_level(rfd::MessageLevel::Error)
.set_description("Can only load one file at a time")
.show();
}
if let Some(file) = egui_ctx.input().raw.dropped_files.first() {
if let Some(file) = egui_ctx.input(|i| i.raw.dropped_files.first().cloned()) {
if let Some(bytes) = &file.bytes {
let mut bytes: &[u8] = &(*bytes)[..];
if let Some(log_db) = load_file_contents(&file.name, &mut bytes) {
Expand All @@ -715,22 +717,24 @@ fn preview_files_being_dropped(egui_ctx: &egui::Context) {
use egui::{Align2, Color32, Id, LayerId, Order, TextStyle};

// Preview hovering files:
if !egui_ctx.input().raw.hovered_files.is_empty() {
if !egui_ctx.input(|i| i.raw.hovered_files.is_empty()) {
use std::fmt::Write as _;

let mut text = "Drop to load:\n".to_owned();
for file in &egui_ctx.input().raw.hovered_files {
if let Some(path) = &file.path {
write!(text, "\n{}", path.display()).ok();
} else if !file.mime.is_empty() {
write!(text, "\n{}", file.mime).ok();
egui_ctx.input(|input| {
for file in &input.raw.hovered_files {
if let Some(path) = &file.path {
write!(text, "\n{}", path.display()).ok();
} else if !file.mime.is_empty() {
write!(text, "\n{}", file.mime).ok();
}
}
}
});

let painter =
egui_ctx.layer_painter(LayerId::new(Order::Foreground, Id::new("file_drop_target")));

let screen_rect = egui_ctx.input().screen_rect();
let screen_rect = egui_ctx.screen_rect();
painter.rect_filled(screen_rect, 0.0, Color32::from_black_alpha(192));
painter.text(
screen_rect.center(),
Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer/src/misc/time_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl TimeControl {
return;
};

let dt = egui_ctx.input().stable_dt.at_most(0.1) * self.speed;
let dt = egui_ctx.input(|i| i.stable_dt).at_most(0.1) * self.speed;

let state = self
.states
Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer/src/misc/viewer_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl<'a> ViewerContext<'a> {
pub fn select_hovered_on_click(&mut self, response: &egui::Response) {
if response.clicked() {
let hovered = self.rec_cfg.selection_state.hovered().clone();
if response.ctx.input().modifiers.command {
if response.ctx.input(|i| i.modifiers.command) {
self.rec_cfg
.selection_state
.toggle_selection(hovered.into_iter());
Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewer/src/remote_viewer_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl eframe::App for RemoteViewerApp {
ui.horizontal(|ui| {
ui.label("URL:");
if ui.text_edit_singleline(&mut self.url).lost_focus()
&& ui.input().key_pressed(egui::Key::Enter)
&& ui.input(|i| i.key_pressed(egui::Key::Enter))
{
if let Some(storage) = frame.storage_mut() {
if let Some((_, mut app)) = self.app.take() {
Expand Down
4 changes: 3 additions & 1 deletion crates/re_viewer/src/ui/memory_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,9 @@ impl MemoryPanel {
.on_hover_text("Click to copy callstack to clipboard")
.clicked()
{
ui.output().copied_text = callstack.readable_backtrace.to_string();
ui.output_mut(|o| {
o.copied_text = callstack.readable_backtrace.to_string();
});
}
}
});
Expand Down
Loading