debug: Fix crashes and deadlocks
This commit is contained in:
parent
4e6713291d
commit
7c222ae6d1
2 changed files with 18 additions and 9 deletions
|
|
@ -219,14 +219,18 @@ impl Timings {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn avg_rendertime(&self) -> Duration {
|
pub fn avg_rendertime(&self) -> Duration {
|
||||||
if self.previous_frames.is_empty() {
|
let Some(sum_rendertime) = self
|
||||||
return Duration::ZERO;
|
.previous_frames
|
||||||
}
|
|
||||||
self.previous_frames
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(|f| f.render_time())
|
.map(|f| f.render_time())
|
||||||
.sum::<Duration>()
|
.try_fold(Duration::ZERO, |acc, x| acc.checked_add(x))
|
||||||
/ (self.previous_frames.len() as u32)
|
else {
|
||||||
|
return Duration::ZERO;
|
||||||
|
};
|
||||||
|
|
||||||
|
sum_rendertime
|
||||||
|
.checked_div(self.previous_frames.len() as u32)
|
||||||
|
.unwrap_or(Duration::ZERO)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn avg_submittime(&self, window: usize) -> Option<Duration> {
|
pub fn avg_submittime(&self, window: usize) -> Option<Duration> {
|
||||||
|
|
@ -269,9 +273,12 @@ impl Timings {
|
||||||
(Some(Frame { render_start, .. }), Some(end_frame)) => {
|
(Some(Frame { render_start, .. }), Some(end_frame)) => {
|
||||||
Time::elapsed(render_start, end_frame.render_start.clone()) + end_frame.frame_time()
|
Time::elapsed(render_start, end_frame.render_start.clone()) + end_frame.frame_time()
|
||||||
}
|
}
|
||||||
_ => Duration::ZERO,
|
_ => {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.as_secs_f64();
|
.as_secs_f64();
|
||||||
|
|
||||||
1.0 / (secs / self.previous_frames.len() as f64)
|
1.0 / (secs / self.previous_frames.len() as f64)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -572,15 +572,16 @@ where
|
||||||
CosmicMappedRenderElement<R>: RenderElement<R>,
|
CosmicMappedRenderElement<R>: RenderElement<R>,
|
||||||
WorkspaceRenderElement<R>: RenderElement<R>,
|
WorkspaceRenderElement<R>: RenderElement<R>,
|
||||||
{
|
{
|
||||||
let shell_guard = shell.read().unwrap();
|
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
let mut debug_elements = {
|
let mut debug_elements = {
|
||||||
let output_geo = output.geometry();
|
let output_geo = output.geometry();
|
||||||
|
let shell_guard = shell.read().unwrap();
|
||||||
let seats = shell_guard.seats.iter().cloned().collect::<Vec<_>>();
|
let seats = shell_guard.seats.iter().cloned().collect::<Vec<_>>();
|
||||||
|
let debug_active = shell_guard.debug_active;
|
||||||
|
std::mem::drop(shell_guard);
|
||||||
let scale = output.current_scale().fractional_scale();
|
let scale = output.current_scale().fractional_scale();
|
||||||
|
|
||||||
if let Some((state, timings)) = _fps {
|
if let Some((state, timings)) = _fps {
|
||||||
let debug_active = shell_guard.debug_active;
|
|
||||||
vec![fps_ui(
|
vec![fps_ui(
|
||||||
_gpu,
|
_gpu,
|
||||||
debug_active,
|
debug_active,
|
||||||
|
|
@ -601,6 +602,7 @@ where
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let shell_guard = shell.read().unwrap();
|
||||||
let Some((previous_workspace, workspace)) = shell_guard.workspaces.active(output) else {
|
let Some((previous_workspace, workspace)) = shell_guard.workspaces.active(output) else {
|
||||||
#[cfg(not(feature = "debug"))]
|
#[cfg(not(feature = "debug"))]
|
||||||
return Ok(Vec::new());
|
return Ok(Vec::new());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue