From 08a6a8fa9c56720170d0a5fc5fc83b962b7af878 Mon Sep 17 00:00:00 2001 From: Danko Curlin Date: Tue, 24 Nov 2026 21:07:07 +0100 Subject: [PATCH] Skip GPU present for hidden viewports on all platforms. Wayland already skipped painting hidden viewports; on Windows/macOS the hidden 1x1 root kept presenting every heartbeat and serialized behind mouse-driven frames, so the cursor felt stuck with quiet CPU/GPU. Still run the UI pass when descendants need it. Co-authored-by: Cursor --- src/native/glow_integration.rs | 20 ++++++-------------- src/native/wgpu_integration.rs | 20 ++++++-------------- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/src/native/glow_integration.rs b/src/native/glow_integration.rs index ad1a69f..8ab9fdb 100644 --- a/src/native/glow_integration.rs +++ b/src/native/glow_integration.rs @@ -627,12 +627,12 @@ impl GlowWinitRunning<'_> { let is_visible = viewport.info.visible().unwrap_or(true); - // Wayland cannot hide a toplevel: a surface that never gets a buffer stays unmapped, - // which is the only hidden state there. Presenting a viewport the app hid would map it, - // and gate its redraws on frame callbacks that the compositor may withhold for a window - // nobody sees (minimized, or on another virtual desktop). So we still run its ui pass, - // but never paint it. - let paint = is_visible && !(viewport.hidden && is_wayland(window)); + // Never present a viewport the app hid. On Wayland that would map an unmapped surface + // and gate redraws on compositor frame callbacks; on Windows/macOS a hidden 1x1 root + // that still presents every heartbeat serializes behind mouse-driven frames on the + // shared device and makes the cursor feel stuck while CPU/GPU stay quiet. UI still + // runs when show_ui is true (so deferred children keep ticking). + let paint = is_visible && !viewport.hidden; let Some(egui_winit) = viewport.egui_winit.as_mut() else { return Ok(EventResult::Wait); @@ -1598,14 +1598,6 @@ fn initialize_or_update_viewport( } } -/// Is this window a Wayland toplevel? -fn is_wayland(window: &Window) -> bool { - matches!( - window.window_handle().map(|handle| handle.as_raw()), - Ok(raw_window_handle::RawWindowHandle::Wayland(_)) - ) -} - /// Is this viewport, or any of its (transitive) descendant viewports, visible? /// /// Immediate viewports are rendered inline while their parent's UI runs, so even diff --git a/src/native/wgpu_integration.rs b/src/native/wgpu_integration.rs index 1493495..64740af 100644 --- a/src/native/wgpu_integration.rs +++ b/src/native/wgpu_integration.rs @@ -679,12 +679,12 @@ impl WgpuWinitRunning<'_> { let is_visible = viewport.info.visible().unwrap_or(true); - // Wayland cannot hide a toplevel: a surface that never gets a buffer stays unmapped, - // which is the only hidden state there. Presenting a viewport the app hid would map it, - // and gate its redraws on frame callbacks that the compositor may withhold for a window - // nobody sees (minimized, or on another virtual desktop). So we still run its ui pass, - // but never paint it. - let paint = is_visible && !(viewport.hidden && is_wayland(window)); + // Never present a viewport the app hid. On Wayland that would map an unmapped surface + // and gate redraws on compositor frame callbacks; on Windows/macOS a hidden 1x1 root + // that still presents every heartbeat serializes behind mouse-driven frames on the + // shared device and makes the cursor feel stuck while CPU/GPU stay quiet. UI still + // runs when show_ui is true (so deferred children keep ticking). + let paint = is_visible && !viewport.hidden; { profiling::scope!("set_window"); @@ -1138,14 +1138,6 @@ fn create_window( Ok((window, viewport_builder)) } -/// Is this window a Wayland toplevel? -fn is_wayland(window: &Window) -> bool { - matches!( - window.window_handle().map(|handle| handle.as_raw()), - Ok(raw_window_handle::RawWindowHandle::Wayland(_)) - ) -} - /// Is this viewport, or any of its (transitive) descendant viewports, visible? /// /// Immediate viewports are rendered inline while their parent's UI runs, so even