From 37fd0cda940ad06df801a9a9aa687a97f99a6877 Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 10 Nov 2022 21:55:53 +0100 Subject: [PATCH] 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... --- src/gui/panel.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gui/panel.rs b/src/gui/panel.rs index 776c381..84d1b2c 100644 --- a/src/gui/panel.rs +++ b/src/gui/panel.rs @@ -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(); } }