fix: maybe no more weird freezes?

this is a weird one: sometimes, after sending some changes to the state
worker, the GUI will completely freeze. No error or panic reported, just
completely frozen, must be terminated and restarted. This is super
annoying! I tried to debug it, and it seems that the main GUI thread
gets blocked inside an unsafe block of crate `parking_lot` invoking a
FUTEX syscall (Fast Userspace muTEX). Climbing up the stack trace, it
seems to be originating from accessing a watch channel, specifically
when rendering panels. I noticed that there were unnecessary borrow
calls, and slimmed them down, and still haven't experienced it again.
Which is weird! Seems like a very "magic" fix, but it is to be expected
with race conditions, and this looks to be the case. I could quite
reliably reproduce it with ~20 metrics on ~4 sources set up.

idk, I just want this fixed, but I'm still super bummed I didn't catch
the culprit...
This commit is contained in:
əlemi 2022-11-10 21:55:53 +01:00
parent ceb7fa6da2
commit 37fd0cda94
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -11,7 +11,9 @@ use crate::data::entities;
use super::scaffold::EditingModel;
pub fn main_content(app: &mut App, ctx: &Context, ui: &mut Ui) {
let panel_metric = app.view.panel_metric.borrow();
let metrics = app.view.metrics.borrow();
let points = app.view.points.borrow();
ScrollArea::vertical().show(ui, |ui| {
ui.separator();
if app.edit {
@ -22,9 +24,9 @@ pub fn main_content(app: &mut App, ctx: &Context, ui: &mut Ui) {
true,
)
.show_header(ui, |ui| {
panel_title_ui_edit(ui, &mut panel, &mut app.editing, &app.view.metrics.borrow(), &app.view.panel_metric.borrow());
panel_title_ui_edit(ui, &mut panel, &mut app.editing, &metrics, &panel_metric);
})
.body(|ui| panel_body_ui(ui, panel, &metrics, &app.view.points.borrow(), &app.view.panel_metric.borrow()));
.body(|ui| panel_body_ui(ui, panel, &metrics, &points, &panel_metric));
ui.separator();
}
} else {
@ -35,9 +37,9 @@ pub fn main_content(app: &mut App, ctx: &Context, ui: &mut Ui) {
true,
)
.show_header(ui, |ui| {
panel_title_ui(ui, &panel, &mut app.editing, &app.view.metrics.borrow(), &app.view.panel_metric.borrow());
panel_title_ui(ui, &panel, &mut app.editing, &metrics, &panel_metric);
})
.body(|ui| panel_body_ui(ui, panel, &metrics, &app.view.points.borrow(), &app.view.panel_metric.borrow()));
.body(|ui| panel_body_ui(ui, panel, &metrics, &points, &panel_metric));
ui.separator();
}
}