Skip to content

fix(power): avoid 25s stall when blanking the screen - #229

Closed
52cyb wants to merge 1 commit into
release/2500u2-pajilfrom
fix/power-blank-screen-2500u2-pajil
Closed

52cyb wants to merge 1 commit into
release/2500u2-pajilfrom
fix/power-blank-screen-2500u2-pajil

Conversation

@52cyb

@52cyb 52cyb commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Bug: https://pms.uniontech.com/bug-view-383573.html

Backport of #217 to release/2500u2-pajil.

fix(power): avoid 25s stall when blanking the screen

  1. TurnOffScreen waited for LockFront ShowAuth while dde-lock read Power1
    SleepLock back, so both sides stalled until the 25s D-Bus timeout and
    the display stayed lit the whole time.
  2. SessionDBusProxy::showLockAuth fire-and-forgets ShowAuth now, and the
    X11 turn-off path blanks the screen before requesting the lock.
  3. dde-shortcut-tool's power controller uses the same async ShowAuth call,
    so the power-button shortcut no longer blocks its key handler.

Log: Blank the screen immediately instead of waiting for LockFront.

Influence:

  1. Press the power button: the display blanks immediately; journalctl shows
    no 25s gap between "Locking session" and "Setting DPMS mode to off".
  2. Lock/unlock, suspend/resume, hibernate and shutdown still work.
  3. Repeat screen-off after a suspend/resume cycle and confirm the display
    still blanks immediately.

fix(power): 修复锁屏回读导致关屏延迟 25 秒

  1. TurnOffScreen 同步等待 LockFront ShowAuth,而 dde-lock 在 ShowAuth
    中回读 Power1 SleepLock,双方互等到 25 秒 D-Bus 超时,期间屏幕
    一直亮着。
  2. SessionDBusProxy::showLockAuth 改为异步发送 ShowAuth 后立即返回,
    X11 关屏路径先关闭显示器再请求锁屏。
  3. dde-shortcut-tool 的电源控制器同样改为异步调用 ShowAuth,按电源键
    不再阻塞快捷键处理。

Log: 立即关闭显示器,不再等待 LockFront 返回。

Influence:

  1. 按电源键后显示器立即熄灭;journalctl 中 "Locking session" 到
    "Setting DPMS mode to off" 不再有 25 秒间隔。
  2. 锁屏/解锁、待机/唤醒、休眠、关机功能正常。
  3. 待机/唤醒后再按一次电源键,确认显示器仍立即关闭。

PMS: BUG-383573

Summary by Sourcery

Eliminate the power-button screen-off stall by blanking the display first and making lock-authentication requests asynchronous.

Bug Fixes:

  • Prevent screen blanking and power-button handling from stalling for 25 seconds when locking the session.
  • Ensure the display turns off immediately before the lock request is processed.

Enhancements:

  • Use non-blocking lock-authentication requests across the power-management and shortcut paths.

1. TurnOffScreen waited for LockFront ShowAuth while dde-lock read Power1
   SleepLock back, so both sides stalled until the 25s D-Bus timeout and
   the display stayed lit the whole time.
2. SessionDBusProxy::showLockAuth fire-and-forgets ShowAuth now, and the
   X11 turn-off path blanks the screen before requesting the lock.
3. dde-shortcut-tool's power controller uses the same async ShowAuth call,
   so the power-button shortcut no longer blocks its key handler.

Log: Blank the screen immediately instead of waiting for LockFront.

Influence:
1. Press the power button: the display blanks immediately; journalctl shows
   no 25s gap between "Locking session" and "Setting DPMS mode to off".
2. Lock/unlock, suspend/resume, hibernate and shutdown still work.
3. Repeat screen-off after a suspend/resume cycle and confirm the display
   still blanks immediately.

fix(power): 修复锁屏回读导致关屏延迟 25 秒

1. TurnOffScreen 同步等待 LockFront ShowAuth,而 dde-lock 在 ShowAuth
   中回读 Power1 SleepLock,双方互等到 25 秒 D-Bus 超时,期间屏幕
   一直亮着。
2. SessionDBusProxy::showLockAuth 改为异步发送 ShowAuth 后立即返回,
   X11 关屏路径先关闭显示器再请求锁屏。
3. dde-shortcut-tool 的电源控制器同样改为异步调用 ShowAuth,按电源键
   不再阻塞快捷键处理。

Log: 立即关闭显示器,不再等待 LockFront 返回。

Influence:
1. 按电源键后显示器立即熄灭;journalctl 中 "Locking session" 到
   "Setting DPMS mode to off" 不再有 25 秒间隔。
2. 锁屏/解锁、待机/唤醒、休眠、关机功能正常。
3. 待机/唤醒后再按一次电源键,确认显示器仍立即关闭。

PMS: BUG-383573

(cherry picked from commit 7391dcb)
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 52cyb

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Nov 20, 2026

Copy link
Copy Markdown

Reviewer's Guide

Uses of the API

Send LockFront ShowAuth requests asynchronously so callers do not block while LockFront reads Power1 properties.

  • src/plugin-qt/power/session/sessiondbusproxy.cpp L340-343
  • src/plugin-qt/shortcut/tools/dde-shortcut-tool/powercontroller.cpp L278-280

Implementation

Blank the display before requesting the screen lock so a delayed lock operation cannot keep the display lit.

  • src/plugin-qt/power/session/powermanager.cpp L644 (removed lines), L646-650

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 3 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/plugin-qt/power/session/sessiondbusproxy.cpp" line_range="343" />
<code_context>
+    // LockFront's handler reads Power1 properties (SleepLock) synchronously. A
+    // blocking call here parks the Power1 main thread until the 25s D-Bus
+    // timeout, which in turn delays whatever triggered the lock (screen-off).
+    m_lockFrontInter->asyncCall("ShowAuth", autoStart);
 }

</code_context>
<issue_to_address>
**Desktop exposed after resume**

When wake-time locking is enabled and the black screen is deactivated before LockFront handles the queued request, the async `doLock(true)` returns before LockFront processes `ShowAuth`, and the wakeup callback immediately calls `setBlackScreenActive(false)`; the display therefore becomes visible before the lock UI is ready, exposing the unlocked session after resume.

Keep the black screen active until LockFront confirms the session is locked or the lock UI is ready.
</issue_to_address>

### Comment 2
<location path="src/plugin-qt/power/session/sessiondbusproxy.cpp" line_range="343" />
<code_context>
+    // LockFront's handler reads Power1 properties (SleepLock) synchronously. A
+    // blocking call here parks the Power1 main thread until the 25s D-Bus
+    // timeout, which in turn delays whatever triggered the lock (screen-off).
+    m_lockFrontInter->asyncCall("ShowAuth", autoStart);
 }

</code_context>
<issue_to_address>
**Suspend can race the lock**

When the suspend or hibernate path requests a lock and proceeds to sleep before LockFront processes the asynchronous request, `PowerManager::doSuspend()` and `doHibernate()` also call `doLock()` before starting sleep; `asyncCall()` returns without waiting for LockFront to finish handling `ShowAuth`, so the machine can suspend before the lock is active and resume to an unlocked session.

Ensure suspend and hibernate wait until the lock is active before entering sleep, while keeping screen-off requests non-blocking.
</issue_to_address>

### Comment 3
<location path="src/plugin-qt/power/session/sessiondbusproxy.cpp" line_range="343" />
<code_context>
+    // LockFront's handler reads Power1 properties (SleepLock) synchronously. A
+    // blocking call here parks the Power1 main thread until the 25s D-Bus
+    // timeout, which in turn delays whatever triggered the lock (screen-off).
+    m_lockFrontInter->asyncCall("ShowAuth", autoStart);
 }

</code_context>
<issue_to_address>
**Overlapping lock prompts**

When two lock triggers arrive before LockFront has processed the first `ShowAuth` request and updated the locked state, each asynchronous request returns before LockFront updates the session’s locked state, so another lock trigger can pass `PowerManager::doLock`’s `sessionLocked()` check and enqueue a second `ShowAuth`; LockFront receives duplicate requests and can present redundant authentication UI.

Track a pending lock request or otherwise coalesce concurrent `ShowAuth` calls until LockFront confirms the lock state.

Also at `src/plugin-qt/shortcut/tools/dde-shortcut-tool/powercontroller.cpp:280`.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

// LockFront's handler reads Power1 properties (SleepLock) synchronously. A
// blocking call here parks the Power1 main thread until the 25s D-Bus
// timeout, which in turn delays whatever triggered the lock (screen-off).
m_lockFrontInter->asyncCall("ShowAuth", autoStart);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · Desktop exposed after resume

When wake-time locking is enabled and the black screen is deactivated before LockFront handles the queued request, the async doLock(true) returns before LockFront processes ShowAuth, and the wakeup callback immediately calls setBlackScreenActive(false); the display therefore becomes visible before the lock UI is ready, exposing the unlocked session after resume.

Keep the black screen active until LockFront confirms the session is locked or the lock UI is ready.

Prompt for AI agents
In `src/plugin-qt/power/session/sessiondbusproxy.cpp` at line 343:

**Desktop exposed after resume**

When wake-time locking is enabled and the black screen is deactivated before LockFront handles the queued request, the async `doLock(true)` returns before LockFront processes `ShowAuth`, and the wakeup callback immediately calls `setBlackScreenActive(false)`; the display therefore becomes visible before the lock UI is ready, exposing the unlocked session after resume.

Keep the black screen active until LockFront confirms the session is locked or the lock UI is ready.

// LockFront's handler reads Power1 properties (SleepLock) synchronously. A
// blocking call here parks the Power1 main thread until the 25s D-Bus
// timeout, which in turn delays whatever triggered the lock (screen-off).
m_lockFrontInter->asyncCall("ShowAuth", autoStart);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · Suspend can race the lock

When the suspend or hibernate path requests a lock and proceeds to sleep before LockFront processes the asynchronous request, PowerManager::doSuspend() and doHibernate() also call doLock() before starting sleep; asyncCall() returns without waiting for LockFront to finish handling ShowAuth, so the machine can suspend before the lock is active and resume to an unlocked session.

Ensure suspend and hibernate wait until the lock is active before entering sleep, while keeping screen-off requests non-blocking.

Prompt for AI agents
In `src/plugin-qt/power/session/sessiondbusproxy.cpp` at line 343:

**Suspend can race the lock**

When the suspend or hibernate path requests a lock and proceeds to sleep before LockFront processes the asynchronous request, `PowerManager::doSuspend()` and `doHibernate()` also call `doLock()` before starting sleep; `asyncCall()` returns without waiting for LockFront to finish handling `ShowAuth`, so the machine can suspend before the lock is active and resume to an unlocked session.

Ensure suspend and hibernate wait until the lock is active before entering sleep, while keeping screen-off requests non-blocking.

// LockFront's handler reads Power1 properties (SleepLock) synchronously. A
// blocking call here parks the Power1 main thread until the 25s D-Bus
// timeout, which in turn delays whatever triggered the lock (screen-off).
m_lockFrontInter->asyncCall("ShowAuth", autoStart);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Overlapping lock prompts

When two lock triggers arrive before LockFront has processed the first ShowAuth request and updated the locked state, each asynchronous request returns before LockFront updates the session’s locked state, so another lock trigger can pass PowerManager::doLock’s sessionLocked() check and enqueue a second ShowAuth; LockFront receives duplicate requests and can present redundant authentication UI.

Track a pending lock request or otherwise coalesce concurrent ShowAuth calls until LockFront confirms the lock state.

Also at src/plugin-qt/shortcut/tools/dde-shortcut-tool/powercontroller.cpp:280.

Prompt for AI agents
In `src/plugin-qt/power/session/sessiondbusproxy.cpp` at line 343:

**Overlapping lock prompts**

When two lock triggers arrive before LockFront has processed the first `ShowAuth` request and updated the locked state, each asynchronous request returns before LockFront updates the session’s locked state, so another lock trigger can pass `PowerManager::doLock`’s `sessionLocked()` check and enqueue a second `ShowAuth`; LockFront receives duplicate requests and can present redundant authentication UI.

Track a pending lock request or otherwise coalesce concurrent `ShowAuth` calls until LockFront confirms the lock state.

Also at `src/plugin-qt/shortcut/tools/dde-shortcut-tool/powercontroller.cpp:280`.

@52cyb 52cyb closed this Nov 20, 2026
@52cyb
52cyb deleted the fix/power-blank-screen-2500u2-pajil branch November 20, 2026 01:53
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.

3 participants