Debugging stuck loop.

This commit is contained in:
Samuel Guerra 2023-12-14 13:51:23 -03:00
parent 4beb390555
commit 4b5b81a8eb
5 changed files with 38 additions and 4 deletions

View File

@ -30,7 +30,9 @@ top 20 most frequent update requests (in 500 cycles):
WindowManager//WindowId(1) update (250 times)
WindowManager//WindowId(1) update var of type zero_ui_units::factor::Factor (250 times)
```
Observed multiple times, after a slow build when the VS window is not focused.
- Observed multiple times, after a slow build when the VS window is not focused.
- Added debug panics in scale_factor vars of window and monitor if they change more then 10 times, lets see.
- Debug panics marked with comment "// debug WindowManager//WindowId(1) update var of type zero_ui_units::factor::Factor (250 times)".
# Hit-test

View File

@ -234,7 +234,7 @@ impl fmt::Debug for MonitorInfo {
impl MonitorInfo {
/// New from a [`zero_ui_view_api::MonitorInfo`].
fn from_gen(id: MonitorId, info: zero_ui_view_api::window::MonitorInfo) -> Self {
MonitorInfo {
let m = MonitorInfo {
id,
is_primary: var(info.is_primary),
name: var(info.name.to_text()),
@ -243,7 +243,23 @@ impl MonitorInfo {
scale_factor: var(info.scale_factor),
video_modes: var(info.video_modes),
ppi: var(Ppi::default()),
};
#[cfg(debug_assertions)]
{
// debug WindowManager//WindowId(1) update var of type zero_ui_units::factor::Factor (250 times)
let mut history = vec![];
m.scale_factor
.trace_value(move |a| {
history.push(*a.value());
if history.len() > 10 {
panic!("MonitorInfo::scale_factor changed >10 times, {history:?}");
}
})
.perm();
}
m
}
/// Update variables from fresh [`zero_ui_view_api::MonitorInfo`],

View File

@ -154,6 +154,21 @@ impl WindowVars {
access_enabled: var(AccessEnabled::empty()),
});
#[cfg(debug_assertions)]
{
// debug WindowManager//WindowId(1) update var of type zero_ui_units::factor::Factor (250 times)
let mut history = vec![];
vars.scale_factor
.trace_value(move |a| {
history.push(*a.value());
if history.len() > 10 {
panic!("WindowVars::scale_factor changed >10 times, {history:?}");
}
})
.perm();
}
Self(vars)
}

View File

@ -32,4 +32,5 @@ bitflags = { version = "2", features = ["serde"] }
bytemuck = { version = "1", features = ["derive"] }
parking_lot = "0.12"
tracing = "0.1"
take_mut = "0.2"
take_mut = "0.2"
pretty-type-name = "1"

View File

@ -245,7 +245,7 @@ impl VARS {
tracing::event!(
target: UPDATES_TARGET,
tracing::Level::TRACE,
{ kind = "update var", type_name }
{ kind = "update var", type_name = pretty_type_name::pretty_type_name_str(type_name) }
);
}