Skip to content

Lower refresh rate on multi-rate panels while idle - #298

Draft
grierj wants to merge 1 commit into
OrchardLinux:mainfrom
grierj:idle-refresh-rate
Draft

grierj wants to merge 1 commit into
OrchardLinux:mainfrom
grierj:idle-refresh-rate

Conversation

@grierj

@grierj grierj commented Dec 5, 2026

Copy link
Copy Markdown

Summary

On tablets and laptops whose built-in display exposes lower refresh rates (>= 24 Hz) at the active resolution (such as ProMotion iPads with 120/60/48/30/24 Hz modes), step down to the lowest safe refresh rate after 5 s of inactivity and restore the previous active mode on the first input or when the shell exits.

Single-mode panels stay completely unaffected (supported: false, no IdleMonitor enabled, zero idle overhead).

Changes

  • desktop/shell/shell/plugins/services/idle/IdleModel.js:
    • selectIdleRefreshPlan(): scans all enabled internal outputs (^(eDP|LVDS|DSI|Unknown)-), finds the first multi-rate panel exposing modes >= 24 Hz at the current resolution, and returns valid, hasEnabledInternal, supported, output, activeMode, and idleMode.
    • shouldRestoreIdleRefresh(): verifies the output is still present, enabled, and holding the exact idle mode applied by this service before restoring, preserving any manual mode or resolution change.
  • desktop/shell/shell/plugins/services/idle/Service.qml:
    • Adds refreshIdleMonitor (IdleMonitor, default 5 s via idle.refreshRate, 0 disables), gated on both idleEnabled (Stay Awake) and respectInhibitors: true (video playback, games), using the same retiming rearm workaround as idleMonitor.
    • Uses declarative reconcileRefreshRate() after every probe/apply exit (with synchronized onStreamFinished + onExited), avoids tight-looping on rejected lowers (refreshLowerFailedThisIdle), retries transient startup/restore failures within a bound, re-probes on Quickshell.onScreensChanged, and runs a verified detached restore on Component.onDestruction (covering in-flight lowers while preserving manual mode changes).
    • Exposes refreshRate state in omarchy-shell idle status.
  • docs/power-and-lock.md: documents idle.refreshRate in the timing table.
  • tests/test_idle_refresh.py: unit tests for mode selection, multi-connector scanning, restore verification, and end-to-end teardown script behavior (normal restore, manual override preservation, in-flight lower settle, and retry on transient failure).

Live verification (J207 / iPad Pro 10.5-inch, 500 mA USB SDP, 53% backlight)

  • Idle 60 Hz → 24 Hz after 5 s, restores 60 Hz on input (Scale: 2.0, Transform preserved).
  • Manual 120 Hz → 24 Hz after 5 s, restores 120 Hz on input.
  • Net battery current on 500 mA USB-A SDP (50–53% backlight):
    • 120 Hz: -195 mA (discharging)
    • 60 Hz: -47 mA (discharging)
    • Auto-24 Hz idle (with idle-wakeups): +80 mA (net charging, saving ~127 mA / ~480 mW vs 60 Hz and ~275 mA / ~1.04 W vs 120 Hz).

On displays whose built-in panel exposes lower refresh rates (>= 24 Hz)
at the active resolution (such as ProMotion iPads with 120/60/48/30/24 Hz
modes), add a Wayland IdleMonitor in the idle service that steps down to
the lowest safe refresh rate after 5 s of inactivity (configurable via
idle.refreshRate, 0 to disable) and restores the previous mode on the
first input or when the shell exits.

- Scan all enabled internal outputs so a single-mode internal connector
  does not hide a multi-rate panel, and retry transient startup probe
  failures cleanly.
- Gate on both idleEnabled (Stay Awake) and respectInhibitors (video
  playback, games), and apply the same IdleMonitor retiming rearm
  workaround used by idleMonitor.
- Reconcile desired state after every probe/apply exit so idle events
  during restore are never dropped, retain saved mode with bounded retry
  on transient restore failures, verify the output still holds our idle
  mode before restoring (so manual mode changes are preserved), and run
  a checked teardown restore covering in-flight lowers.

Assisted-by: LLM
@grierj
grierj marked this pull request as draft December 5, 2026 02:44
@grierj

grierj commented Dec 5, 2026

Copy link
Copy Markdown
Author

Marking as draft while we fix a ~19 ms black-frame flash on same-resolution refresh-rate modesets in labwc/wlroots ("Attaching empty buffer to output for modeset" submits a zero-filled black FB before the next painted frame). Once modesets preserve the current image cleanly without flashing black, we'll un-draft this PR.

@grierj

grierj commented Dec 5, 2026

Copy link
Copy Markdown
Author

Keeping this PR in draft until OrchardLinux/packages#40 (wlroots0.20 1:0.20.2-3) lands and is available in [orchard].

Without that wlroots0.20 fix, same-resolution refresh-rate switches flash a solid black frame (~19 ms on J207 simpledrm) before labwc repaints. Verified on J207 that wlroots0.20 1:0.20.2-3 eliminates the flicker across 24 / 30 / 48 / 60 / 120 Hz switches; once OrchardLinux/packages#40 is published we can mark this ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant