1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-26 14:49:06 -04:00

Configure wgpu to be low-latency by default (#8203)

* initially done in https://github.com/emilk/egui/pull/8103, reverted in
#8167 due to resize hangs
* Related: https://github.com/emilk/egui/issues/8043 (maybe closes??)

Turns out the resize hangs were caused by the present_with_transaction
call. Disabling that when `desired_maximum_frame_latency == 1` causes
the window to resize smoothly.

Thanks @krisdigital for noticing that connection:
https://github.com/emilk/egui/issues/8043#issuecomment-4154440382

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
Lucas Meurer
2026-05-26 15:49:51 +02:00
committed by GitHub
parent fd57895559
commit 8d5a7b4557
2 changed files with 21 additions and 17 deletions

View File

@@ -87,13 +87,10 @@ impl SurfaceConfig {
pub const LOW_LATENCY: Self = Self {
present_mode: wgpu::PresentMode::AutoVsync,
#[expect(clippy::branches_sharing_code)]
desired_maximum_frame_latency: if cfg!(target_os = "ios") {
None // The default is good on iOS, while `Some(1)` cuts FPS in half
} else {
// TODO(emilk): We would like yo use `Some(1)` here, but
// that causes bugs when resizing the window on macOS.
None
Some(1)
},
};

View File

@@ -414,6 +414,12 @@ impl Painter {
// See https://github.com/emilk/egui/issues/903
#[cfg(all(target_os = "macos", feature = "macos-window-resize-jitter-fix"))]
{
// setPresentsWithTransaction causes hangs when desired_maximum_frame_latency == 1
let is_low_latency = self
.render_state
.as_ref()
.is_some_and(|rs| rs.surface_config.desired_maximum_frame_latency == Some(1));
if !is_low_latency {
// SAFETY: The cast is checked with if condition. If the used backend is not metal
// it gracefully fails.
unsafe {
@@ -431,6 +437,7 @@ impl Painter {
}
}
}
}
state.resizing = resizing;
}