From fa2d2a40cec25a07046236aab68f44dea2b2dbe8 Mon Sep 17 00:00:00 2001 From: Lionel DARNIS Date: Fri, 21 Aug 2026 09:54:33 +0200 Subject: [PATCH] session: plafonne les trames pre-rendues par le pilote NVIDIA Passe __GL_MaxFramesAllowed=1 a cosmic-comp lorsque /proc/driver/nvidia existe. Sans cela le pilote laisse grossir sa file de trames pre-rendues, ce qui ajoute de la latence a l'affichage (smithay#1562, cosmic-comp#1179). La variable n'est ajoutee que sur machine NVIDIA ; ailleurs l'environnement transmis reste le seul COSMIC_SESSION_SOCK. Co-Authored-By: Claude Opus 5 (1M context) --- Cargo.lock | 16 ++++++++-------- src/comp.rs | 11 ++++++++++- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index efb8899..33d25c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1889,14 +1889,6 @@ dependencies = [ name = "softbuffer" version = "0.4.1" -[[patch.unused]] -name = "cosmic-freedesktop-icons" -version = "0.4.0" - -[[patch.unused]] -name = "smithay-clipboard" -version = "0.8.0" - [[patch.unused]] name = "dpi" version = "0.1.2" @@ -1944,3 +1936,11 @@ version = "0.31.0-beta.2" [[patch.unused]] name = "winit-x11" version = "0.31.0-beta.2" + +[[patch.unused]] +name = "cosmic-freedesktop-icons" +version = "0.4.0" + +[[patch.unused]] +name = "smithay-clipboard" +version = "0.8.0" diff --git a/src/comp.rs b/src/comp.rs index 8457d08..47ec37c 100644 --- a/src/comp.rs +++ b/src/comp.rs @@ -122,12 +122,21 @@ pub fn run_compositor( Ok(tokio::spawn(async move { // Create a new process handler for cosmic-comp, with our compositor socket's // file descriptor as the `COSMIC_SESSION_SOCK` environment variable. + let mut comp_env = vec![( + "COSMIC_SESSION_SOCK".to_string(), + comp.as_raw_fd().to_string(), + )]; + // NVIDIA keeps a growing pool of pre-rendered compositor frames + // (smithay#1562 / cosmic-comp#1179). Cap it to a single buffer. + if std::path::Path::new("/proc/driver/nvidia").exists() { + comp_env.push(("__GL_MaxFramesAllowed".to_string(), "1".to_string())); + } process_manager .start_process( Process::new() .with_executable(exec) .with_args(args) - .with_env([("COSMIC_SESSION_SOCK", comp.as_raw_fd().to_string())]) + .with_env(comp_env) .with_on_exit(move |pman, _, err_code, _will_restart| { let session_dbus_tx = session_dbus_tx.clone(); async move {