diff --git a/crates/fj-viewer/src/graphics/renderer.rs b/crates/fj-viewer/src/graphics/renderer.rs index 64ad13b1d..092e110a3 100644 --- a/crates/fj-viewer/src/graphics/renderer.rs +++ b/crates/fj-viewer/src/graphics/renderer.rs @@ -176,7 +176,7 @@ impl Renderer { format: color_format, width, height, - present_mode: wgpu::PresentMode::Mailbox, + present_mode: wgpu::PresentMode::AutoVsync, }; surface.configure(&device, &surface_config); @@ -324,7 +324,20 @@ impl Renderer { bytemuck::cast_slice(&[uniforms]), ); - let surface_texture = self.surface.get_current_texture()?; + let surface_texture = match self.surface.get_current_texture() { + Ok(surface_texture) => surface_texture, + Err(wgpu::SurfaceError::Timeout) => { + // I'm seeing this all the time now (as in, multiple times per + // microsecond), which `PresentMode::AutoVsync`. Not sure what's + // going on, but for now, it works to just ignore it. + // + // Issues for reference: + // - https://github.com/gfx-rs/wgpu/issues/1218 + // - https://github.com/gfx-rs/wgpu/issues/1565 + return Ok(()); + } + result => result?, + }; let color_view = surface_texture .texture .create_view(&wgpu::TextureViewDescriptor::default()); @@ -669,24 +682,24 @@ impl Renderer { /// Error describing the set of render surface initialization errors #[derive(Error, Debug)] pub enum InitError { - #[error("I/O error: {0}")] /// General IO error + #[error("I/O error: {0}")] Io(#[from] io::Error), - #[error("Error request adapter")] /// Graphics accelerator acquisition error + #[error("Error request adapter")] RequestAdapter, - #[error("Error requesting device: {0}")] /// Device request errors /// /// See: [wgpu::RequestDeviceError](https://docs.rs/wgpu/latest/wgpu/struct.RequestDeviceError.html) + #[error("Error requesting device: {0}")] RequestDevice(#[from] wgpu::RequestDeviceError), - #[error("Error loading font: {0}")] /// Error loading font /// /// See: [ab_glyph::InvalidFont](https://docs.rs/ab_glyph/latest/ab_glyph/struct.InvalidFont.html) + #[error("Error loading font: {0}")] InvalidFont(#[from] InvalidFont), } @@ -695,14 +708,14 @@ pub enum InitError { /// Describes errors related to non initialization graphics errors. #[derive(Error, Debug)] pub enum DrawError { - #[error("Error acquiring output surface: {0}")] /// Surface drawing error. /// /// See - [wgpu::SurfaceError](https://docs.rs/wgpu/latest/wgpu/enum.SurfaceError.html) + #[error("Error acquiring output surface: {0}")] Surface(#[from] wgpu::SurfaceError), - #[error("Error drawing text: {0}")] /// Text rasterisation error. + #[error("Error drawing text: {0}")] Text(String), }