Skip to content

Commit 034cb33

Browse files
authored
Update egui with deadlock fix (#911)
1 parent 0145234 commit 034cb33

15 files changed

+178
-163
lines changed

Cargo.lock

+13-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+15-10
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,14 @@ arrow2_convert = { git = "https://github.com/rerun-io/arrow2-convert", rev = "7e
6767
# arrow2 = { path = "../arrow2" }
6868
# arrow2_convert = { path = "../arrow2-convert/arrow2_convert" }
6969

70-
# 2022-01-24: allow hiding button backgrounds
71-
ecolor = { git = "https://github.com/emilk/egui", rev = "eee4cf6a824e21141bb893aae2aea7849c0e9e03" }
72-
eframe = { git = "https://github.com/emilk/egui", rev = "eee4cf6a824e21141bb893aae2aea7849c0e9e03" }
73-
egui = { git = "https://github.com/emilk/egui", rev = "eee4cf6a824e21141bb893aae2aea7849c0e9e03" }
74-
egui_extras = { git = "https://github.com/emilk/egui", rev = "eee4cf6a824e21141bb893aae2aea7849c0e9e03" }
75-
egui-wgpu = { git = "https://github.com/emilk/egui", rev = "eee4cf6a824e21141bb893aae2aea7849c0e9e03" }
76-
emath = { git = "https://github.com/emilk/egui", rev = "eee4cf6a824e21141bb893aae2aea7849c0e9e03" }
77-
epaint = { git = "https://github.com/emilk/egui", rev = "eee4cf6a824e21141bb893aae2aea7849c0e9e03" }
78-
70+
# 2023-01-25 - egui deadlock fix
71+
ecolor = { git = "https://github.com/emilk/egui", rev = "8ce0e1c5206780e76234842b94ceb0edf5bb8b75" }
72+
eframe = { git = "https://github.com/emilk/egui", rev = "8ce0e1c5206780e76234842b94ceb0edf5bb8b75" }
73+
egui = { git = "https://github.com/emilk/egui", rev = "8ce0e1c5206780e76234842b94ceb0edf5bb8b75" }
74+
egui_extras = { git = "https://github.com/emilk/egui", rev = "8ce0e1c5206780e76234842b94ceb0edf5bb8b75" }
75+
egui-wgpu = { git = "https://github.com/emilk/egui", rev = "8ce0e1c5206780e76234842b94ceb0edf5bb8b75" }
76+
emath = { git = "https://github.com/emilk/egui", rev = "8ce0e1c5206780e76234842b94ceb0edf5bb8b75" }
77+
epaint = { git = "https://github.com/emilk/egui", rev = "8ce0e1c5206780e76234842b94ceb0edf5bb8b75" }
7978
# ecolor = { path = "../../egui/crates/ecolor" }
8079
# eframe = { path = "../../egui/crates/eframe" }
8180
# egui = { path = "../../egui/crates/egui" }
@@ -84,7 +83,13 @@ epaint = { git = "https://github.com/emilk/egui", rev = "eee4cf6a824e21141bb893a
8483
# emath = { path = "../../egui/crates/emath" }
8584
# epaint = { path = "../../egui/crates/epaint" }
8685

87-
# 2022-10-12 - Alpha to coverage support for GLES
86+
# Forks of 3rd party egui crates, tracking latest egui/master:
87+
egui_dock = { git = "https://github.com/rerun-io/egui_dock", rev = "1355a9f24e99518ef7b9546872a0f25ffe1f91d2" } # https://github.com/Adanos020/egui_dock/pull/93
88+
egui-notify = { git = "https://github.com/rerun-io/egui-notify", rev = "a158c2b81ca69ac78e3c61a705f478e8af76fd7d" } # https://github.com/ItsEthra/egui-notify/pull/10
89+
# egui_dock = { path = "../../forks/egui_dock" }
90+
# egui-notify = { path = "../../forks/egui-notify" }
91+
92+
# 2023-10-12 - Alpha to coverage support for GLES
8893
wgpu = { git = "https://github.com/gfx-rs/wgpu.git", ref = "a377ae2b7fe6c1c9412751166f0917e617164e49" }
8994
wgpu-core = { git = "https://github.com/gfx-rs/wgpu.git", ref = "a377ae2b7fe6c1c9412751166f0917e617164e49" }
9095
# wgpu = { path = "../wgpu/wgpu" }

crates/re_ui/src/command.rs

+9-8
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,21 @@ impl Command {
167167
pub fn listen_for_kb_shortcut(egui_ctx: &egui::Context) -> Option<Command> {
168168
use strum::IntoEnumIterator as _;
169169

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

175-
let mut input = egui_ctx.input_mut();
176-
for command in Command::iter() {
177-
if let Some(kb_shortcut) = command.kb_shortcut() {
178-
if input.consume_shortcut(&kb_shortcut) {
179-
return Some(command);
175+
egui_ctx.input_mut(|input| {
176+
for command in Command::iter() {
177+
if let Some(kb_shortcut) = command.kb_shortcut() {
178+
if input.consume_shortcut(&kb_shortcut) {
179+
return Some(command);
180+
}
180181
}
181182
}
182-
}
183-
None
183+
None
184+
})
184185
}
185186

186187
/// Show this command as a menu-button.

crates/re_ui/src/command_palette.rs

+7-11
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ impl CommandPalette {
1919
/// Show the command palette, if it is visible.
2020
#[must_use = "Returns the command that was selected"]
2121
pub fn show(&mut self, egui_ctx: &egui::Context) -> Option<Command> {
22-
self.visible &= !egui_ctx
23-
.input_mut()
24-
.consume_key(Default::default(), Key::Escape);
22+
self.visible &= !egui_ctx.input_mut(|i| i.consume_key(Default::default(), Key::Escape));
2523
if !self.visible {
2624
self.query.clear();
2725
return None;
2826
}
2927

30-
let screen_rect = egui_ctx.input().screen_rect();
28+
let screen_rect = egui_ctx.screen_rect();
3129
let width = 300.0;
3230
let max_height = 320.0.at_most(screen_rect.height());
3331

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

4846
let text_response = ui.add(
4947
egui::TextEdit::singleline(&mut self.query)
@@ -78,8 +76,8 @@ impl CommandPalette {
7876
enter_pressed: bool,
7977
mut scroll_to_selected_alternative: bool,
8078
) -> Option<Command> {
81-
scroll_to_selected_alternative |= ui.input().key_pressed(Key::ArrowUp);
82-
scroll_to_selected_alternative |= ui.input().key_pressed(Key::ArrowDown);
79+
scroll_to_selected_alternative |= ui.input(|i| i.key_pressed(Key::ArrowUp));
80+
scroll_to_selected_alternative |= ui.input(|i| i.key_pressed(Key::ArrowDown));
8381

8482
let query = self.query.to_lowercase();
8583

@@ -159,12 +157,10 @@ impl CommandPalette {
159157

160158
// Move up/down in the list:
161159
self.selected_alternative = self.selected_alternative.saturating_sub(
162-
ui.input_mut()
163-
.count_and_consume_key(Default::default(), Key::ArrowUp),
160+
ui.input_mut(|i| i.count_and_consume_key(Default::default(), Key::ArrowUp)),
164161
);
165162
self.selected_alternative = self.selected_alternative.saturating_add(
166-
ui.input_mut()
167-
.count_and_consume_key(Default::default(), Key::ArrowDown),
163+
ui.input_mut(|i| i.count_and_consume_key(Default::default(), Key::ArrowDown)),
168164
);
169165

170166
self.selected_alternative = self

crates/re_ui/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl ReUi {
158158
/// Paint a watermark
159159
pub fn paint_watermark(&self) {
160160
let logo = self.rerun_logo();
161-
let screen_rect = self.egui_ctx.input().screen_rect;
161+
let screen_rect = self.egui_ctx.screen_rect();
162162
let size = logo.size_vec2();
163163
let rect = Align2::RIGHT_BOTTOM
164164
.align_size_within_rect(size, screen_rect)

crates/re_viewer/src/app.rs

+17-13
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,10 @@ impl eframe::App for App {
492492

493493
self.run_pending_commands(egui_ctx, frame);
494494

495-
self.frame_time_history
496-
.add(egui_ctx.input().time, frame_start.elapsed().as_secs_f32());
495+
self.frame_time_history.add(
496+
egui_ctx.input(|i| i.time),
497+
frame_start.elapsed().as_secs_f32(),
498+
);
497499
}
498500
}
499501

@@ -667,7 +669,7 @@ impl App {
667669

668670
// Keep the style:
669671
let style = egui_ctx.style();
670-
*egui_ctx.memory() = Default::default();
672+
egui_ctx.memory_mut(|mem| *mem = Default::default());
671673
egui_ctx.set_style((*style).clone());
672674
}
673675

@@ -684,13 +686,13 @@ impl App {
684686
preview_files_being_dropped(egui_ctx);
685687

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

717719
// Preview hovering files:
718-
if !egui_ctx.input().raw.hovered_files.is_empty() {
720+
if !egui_ctx.input(|i| i.raw.hovered_files.is_empty()) {
719721
use std::fmt::Write as _;
720722

721723
let mut text = "Drop to load:\n".to_owned();
722-
for file in &egui_ctx.input().raw.hovered_files {
723-
if let Some(path) = &file.path {
724-
write!(text, "\n{}", path.display()).ok();
725-
} else if !file.mime.is_empty() {
726-
write!(text, "\n{}", file.mime).ok();
724+
egui_ctx.input(|input| {
725+
for file in &input.raw.hovered_files {
726+
if let Some(path) = &file.path {
727+
write!(text, "\n{}", path.display()).ok();
728+
} else if !file.mime.is_empty() {
729+
write!(text, "\n{}", file.mime).ok();
730+
}
727731
}
728-
}
732+
});
729733

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

733-
let screen_rect = egui_ctx.input().screen_rect();
737+
let screen_rect = egui_ctx.screen_rect();
734738
painter.rect_filled(screen_rect, 0.0, Color32::from_black_alpha(192));
735739
painter.text(
736740
screen_rect.center(),

crates/re_viewer/src/misc/time_control.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl TimeControl {
106106
return;
107107
};
108108

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

111111
let state = self
112112
.states

crates/re_viewer/src/misc/viewer_context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl<'a> ViewerContext<'a> {
241241
pub fn select_hovered_on_click(&mut self, response: &egui::Response) {
242242
if response.clicked() {
243243
let hovered = self.rec_cfg.selection_state.hovered().clone();
244-
if response.ctx.input().modifiers.command {
244+
if response.ctx.input(|i| i.modifiers.command) {
245245
self.rec_cfg
246246
.selection_state
247247
.toggle_selection(hovered.into_iter());

crates/re_viewer/src/remote_viewer_app.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl eframe::App for RemoteViewerApp {
7878
ui.horizontal(|ui| {
7979
ui.label("URL:");
8080
if ui.text_edit_singleline(&mut self.url).lost_focus()
81-
&& ui.input().key_pressed(egui::Key::Enter)
81+
&& ui.input(|i| i.key_pressed(egui::Key::Enter))
8282
{
8383
if let Some(storage) = frame.storage_mut() {
8484
if let Some((_, mut app)) = self.app.take() {

crates/re_viewer/src/ui/memory_panel.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,9 @@ impl MemoryPanel {
290290
.on_hover_text("Click to copy callstack to clipboard")
291291
.clicked()
292292
{
293-
ui.output().copied_text = callstack.readable_backtrace.to_string();
293+
ui.output_mut(|o| {
294+
o.copied_text = callstack.readable_backtrace.to_string();
295+
});
294296
}
295297
}
296298
});

0 commit comments

Comments
 (0)