Skip to content

Commit 9870364

Browse files
committed
Only issue warning when buffers > 3
1 parent e1edabd commit 9870364

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/backends/cg.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,15 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> SurfaceInterface<D, W> for CGImpl<
317317
self.buffers.push(Buffer::new(self.width, self.height));
318318
// This should have no effect on latency, but it will affect the `buffer.age()` that
319319
// users see, and unbounded allocation is undesirable too, so we should try to avoid it.
320-
tracing::warn!("had to allocate extra buffer in `next_buffer`, you might be rendering faster than the display rate?");
320+
321+
if self.buffers.len() <= 3 {
322+
// Winit currently might emit redraw events twice in a single frame, so we need an
323+
// extra buffer there, see https://github.com/rust-windowing/winit/issues/2640.
324+
// TODO(madsmtm): Always issue a warning once the Winit issue is fixed.
325+
tracing::debug!("had to allocate extra buffer in `next_buffer`, this is probably a bug in Winit's RedrawRequested");
326+
} else {
327+
tracing::warn!("had to allocate extra buffer in `next_buffer`, you might be rendering faster than the event loop can handle?");
328+
}
321329
}
322330

323331
Ok(BufferImpl {

0 commit comments

Comments
 (0)