From 79fc270fc0c6e942cce05600bd01591ef1f390d1 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 7 Apr 2022 19:01:02 +0200 Subject: [PATCH 1/4] Demote panic to warning I'm running into a case where this error is returned all the time, but everything still works. Constant warnings are certainly annoying, but they're better than the app not working at all. --- fj-app/src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fj-app/src/main.rs b/fj-app/src/main.rs index 910805161..31396f808 100644 --- a/fj-app/src/main.rs +++ b/fj-app/src/main.rs @@ -15,7 +15,7 @@ use fj_kernel::algorithms::triangulate; use fj_math::{Aabb, Scalar, Triangle}; use fj_operations::ToShape as _; use futures::executor::block_on; -use tracing::trace; +use tracing::{trace, warn}; use tracing_subscriber::fmt::format; use tracing_subscriber::EnvFilter; use winit::{ @@ -227,7 +227,7 @@ fn main() -> anyhow::Result<()> { match renderer.draw(camera, &draw_config) { Ok(()) => {} Err(err) => { - panic!("Draw error: {}", err); + warn!("Draw error: {}", err); } } } From e13fbf92a9b654093948c52e5c7b135359e5b0bd Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 7 Apr 2022 19:04:19 +0200 Subject: [PATCH 2/4] Simplify error handling code --- fj-app/src/main.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fj-app/src/main.rs b/fj-app/src/main.rs index 31396f808..bea1e38db 100644 --- a/fj-app/src/main.rs +++ b/fj-app/src/main.rs @@ -224,11 +224,8 @@ fn main() -> anyhow::Result<()> { if let (Some(shape), Some(camera)) = (&shape, &mut camera) { camera.update_planes(&shape.aabb); - match renderer.draw(camera, &draw_config) { - Ok(()) => {} - Err(err) => { - warn!("Draw error: {}", err); - } + if let Err(err) = renderer.draw(camera, &draw_config) { + warn!("Draw error: {}", err); } } } From 6973eaebc50e0cc22fb41b694aa132b320834cbb Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 7 Apr 2022 19:07:52 +0200 Subject: [PATCH 3/4] Improve graphics error messages --- fj-app/src/graphics/renderer.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fj-app/src/graphics/renderer.rs b/fj-app/src/graphics/renderer.rs index ad6b10d7c..df89f52ab 100644 --- a/fj-app/src/graphics/renderer.rs +++ b/fj-app/src/graphics/renderer.rs @@ -300,24 +300,24 @@ impl Renderer { #[derive(Error, Debug)] pub enum InitError { - #[error("I/O error")] + #[error("I/O error: {0}")] Io(#[from] io::Error), #[error("Error request adapter")] RequestAdapter, - #[error("Error requesting device")] + #[error("Error requesting device: {0}")] RequestDevice(#[from] wgpu::RequestDeviceError), - #[error("Error loading font")] + #[error("Error loading font: {0}")] InvalidFont(#[from] InvalidFont), } #[derive(Error, Debug)] pub enum DrawError { - #[error("Error acquiring output surface")] + #[error("Error acquiring output surface: {0}")] Surface(#[from] wgpu::SurfaceError), - #[error("Error drawing text")] + #[error("Error drawing text: {0}")] Text(String), } From 625088dc5aeb43aa7cc03c799518589fb8e70b39 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Thu, 7 Apr 2022 19:26:35 +0200 Subject: [PATCH 4/4] Switch present mode to "mailbox" I'm running into this issue: https://github.com/gfx-rs/wgpu/issues/1218 I'm not aware of any adverse effects of switching to `PresentMode::Mailbox`, except that it's "not optimal for mobile", according to the wgpu documentation. Since we don't currently support any mobile platforms, I think this is fine for now. --- fj-app/src/graphics/renderer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fj-app/src/graphics/renderer.rs b/fj-app/src/graphics/renderer.rs index df89f52ab..f77b0eb07 100644 --- a/fj-app/src/graphics/renderer.rs +++ b/fj-app/src/graphics/renderer.rs @@ -75,7 +75,7 @@ impl Renderer { format: color_format, width: window.width(), height: window.height(), - present_mode: wgpu::PresentMode::Fifo, + present_mode: wgpu::PresentMode::Mailbox, }; surface.configure(&device, &surface_config);