Lid close: suspend still happens after the lid is reopened, because the lock-screen call blocks csd-power

Aperta
#480 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c
Ambito
backend

Direzione di ricerca

Start with plugins/power/csd-power-manager.c, especially do_lid_closed_action(), suspend_with_lid_closed(), activate_screensaver(), and handle_suspend_actions(). Trace how the blocking lock call and lid_is_closed state affect suspension, then check how lid events and the existing PrepareForSleep lock are handled. Done means reopening the lid during a cold screensaver start prevents the pending suspend while preserving lock behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

When the lid is closed, csd-power first locks the screen and then suspends. The lock call is
synchronous and blocks the daemon's main loop until the lock screen is up. If cinnamon-screensaver
is not already running, this takes 4–20 s on my machine. If the lid is reopened during that time,
csd-power cannot process the lid-open event, and it suspends anyway as soon as the lock call returns.
The machine goes to sleep with the lid open. In my case, on wake-up the lock screen was then stuck:
the desktop was visible but nothing reacted, and there was no password box (see the related
cinnamon-screensaver issue).

System

  • Linux Mint 22.3 (zena), Cinnamon 6.6.9, cinnamon-settings-daemon 6.6.4+zena,
    cinnamon-screensaver 6.6.2+mint22.3, X11
  • Kernel 7.0.0-42-generic, Lenovo notebook, Intel UHD 630 + NVIDIA GTX 1050 Ti Max-Q
    (PRIME on-demand, driver 580.178.04; the panel is driven by i915), 3840×2160 panel, scale 2
  • lid-close-ac-action = lid-close-battery-action = suspend, lock-on-suspend = true,
    lock-delay = 0
  • Sleep mode: deep (S3). The NVIDIA suspend/resume services ran cleanly (no errors).

Timeline of the failure (journal)

16:17:05  systemd-logind: Lid closed.
16:17:08  dbus: activating org.cinnamon.ScreenSaver (requested by cinnamon-screensaver-command)
16:17:09  cinnamon-screensaver: Starting screensaver...
16:17:11  systemd-logind: Lid opened.            <-- lid reopened before suspend
16:17:21  systemd-logind: The system will suspend now!
16:17:22  kernel: PM: suspend entry (deep)
16:20:24  kernel: PM: suspend exit               (no further lock-screen output, UI unresponsive)

Delay from lid close to suspend over the same day, with the screensaver started fresh each time:
4 s, 5 s, 10 s, 20 s, 16 s, 16 s. With a resident screensaver (cinnamon-screensaver --hold)
the delay drops to about 0.95 s:

18:00:07.54  Lid closed.
18:00:08.48  The system will suspend now!

So the race window is the screensaver's cold start, plus the fact that the result of that wait is
never checked against the current lid state.

Cause (from reading plugins/power/csd-power-manager.c on master)

  1. do_lid_closed_action() → suspend_with_lid_closed() → do_power_action_type():
    case CSD_POWER_ACTION_SUSPEND:
            if (should_lock_on_suspend (manager)) {
                    activate_screensaver (manager, TRUE);
            }
            csd_power_suspend (...);
    
  2. activate_screensaver() runs
    g_spawn_command_line_sync ("cinnamon-screensaver-command --lock", ...).
    This blocks the main loop, with no timeout, until the lock screen is fully up.
  3. While it is blocked, lid_state_changed_cb() / do_lid_open_action() cannot run.
    After the call returns, csd_power_suspend() is called without re-checking
    lid_is_closed.
  4. The screen is locked a second time in handle_suspend_actions() (on PrepareForSleep,
    which already holds a sleep/delay inhibitor for locking). A debug log of
    cinnamon-screensaver shows two Lock requests about 0.8 s apart for a single lid close.

Suggested fix

  • Lock asynchronously (g_spawn_async, or an async D-Bus call to org.cinnamon.ScreenSaver.Lock),
    so the main loop keeps handling lid events.
  • In the completion callback, suspend only if the lid is still closed. If the lid was opened
    in between, cancel the pending suspend.
  • Possibly drop the lock before suspend in the lid path entirely, and rely on the existing
    PrepareForSleep + delay-inhibitor lock in handle_suspend_actions().

Workaround

An autostart entry with cinnamon-screensaver --hold keeps the screensaver resident. This shrinks
the window to about 1 s, but does not close it.

Lingua principale
C
Stelle
70
Fork
81
Merge medio
2g 7h
PR unite (30g)
2

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di linuxmint/cinnamon-settings-daemon

Tutte le issue di linuxmint/cinnamon-settings-daemon

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.