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) <noreply@anthropic.com>
This commit is contained in:
Lionel DARNIS 2026-08-21 09:54:33 +02:00
parent bc61bfddcc
commit fa2d2a40ce
2 changed files with 18 additions and 9 deletions

View file

@ -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 {