1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 13:50:04 -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

@@ -414,20 +414,27 @@ impl Painter {
// See https://github.com/emilk/egui/issues/903
#[cfg(all(target_os = "macos", feature = "macos-window-resize-jitter-fix"))]
{
// SAFETY: The cast is checked with if condition. If the used backend is not metal
// it gracefully fails.
unsafe {
if let Some(hal_surface) = state.surface.as_hal::<wgpu::hal::api::Metal>() {
hal_surface
.render_layer()
.lock()
.setPresentsWithTransaction(resizing);
// 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 {
if let Some(hal_surface) = state.surface.as_hal::<wgpu::hal::api::Metal>() {
hal_surface
.render_layer()
.lock()
.setPresentsWithTransaction(resizing);
Self::configure_surface(
state,
self.render_state.as_ref().unwrap(),
&self.config.surface,
);
Self::configure_surface(
state,
self.render_state.as_ref().unwrap(),
&self.config.surface,
);
}
}
}
}