Skip to content

fix(power): activate Power1 via dsm and fix lock stall - #230

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:release/2500u2-pajilfrom
52cyb:fix/power-blank-stall-2500u2pajil
Nov 20, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:release/2500u2-pajilfrom
52cyb:fix/power-blank-stall-2500u2pajil

Conversation

@52cyb

@52cyb 52cyb commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

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

Backport of 25bc9eb + 7391dcb to release/2500u2-pajil, squashed into one
commit.

  1. The session D-Bus service file declared
    SystemdService=org.deepin.dde.Power1.service, but dde-services never
    shipped that unit, so journald showed Unit ... not found and dde-lock
    logged read SleepLock property failed.
  2. dde-lock's synchronous SleepLock read started a dedicated dsm instance
    whose power plugin synchronously introspected LockFront1/ShutdownFront1
    exported by dde-lock, causing a 25s mutual wait.
  3. Activate Power1 through deepin-service-manager's shared plugin template,
    drop the unused dedicated unit, and replace the front DDBusInterface
    proxies with raw QDBusMessage calls so plugin startup no longer
    introspects dde-lock services.
  4. TurnOffScreen blanked the screen only after doLock(true); it now calls
    setDPMSModeOff() first, and showLockAuth plus PowerController::doLock
    fire-and-forget ShowAuth so neither path blocks on LockFront's Power1
    readback.

Log: 修复 Power1 激活方式与锁屏死锁,并立即关闭显示器。
PMS: BUG-383573

@sourcery-ai

sourcery-ai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Make front-end D-Bus calls nonblocking to avoid synchronous introspection and lock-auth readback stalls, and blank the display before requesting the lock.

  • src/plugin-qt/power/session/powermanager.cpp L644 (removed lines), L646-650
  • src/plugin-qt/power/session/sessiondbusproxy.cpp L25-30, L340-346, L378-382 (+6 small edits)
  • src/plugin-qt/shortcut/tools/dde-shortcut-tool/powercontroller.cpp L278-280

Remove the D-Bus interface members replaced by raw asynchronous calls.

  • src/plugin-qt/power/session/sessiondbusproxy.h L154 (removed lines)

Configuration

Update Power1 D-Bus service activation to use the shared service-manager plugin template and remove the unused dedicated service unit.

  • src/plugin-qt/power/session/misc/dbus/org.deepin.dde.Power1.service L4
  • src/plugin-qt/power/session/misc/org.deepin.dde.Power1.service (deleted)

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 2 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="346" />
<code_context>
+    QDBusMessage msg = QDBusMessage::createMethodCall(
+        kLockFront, kLockFrontPath, kLockFront, QStringLiteral("ShowAuth"));
+    msg << autoStart;
+    QDBusConnection::sessionBus().asyncCall(msg);
 }

</code_context>
<issue_to_address>
**Actions proceed before locking completes**

When lockFront takes longer than the shortcut's 500 ms delay to process `ShowAuth`, `asyncCall` returns without waiting for LockFront to handle `ShowAuth`. In the shortcut suspend path, `handleSystemSuspend` then proceeds to suspend after a fixed 500 ms without checking lock state; a slow LockFront can leave the session unlocked when the machine suspends and resumes.

Before suspending, wait for confirmation that the session is locked, with a bounded timeout and a safe failure behavior.

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

### Comment 2
<location path="src/plugin-qt/shortcut/tools/dde-shortcut-tool/powercontroller.cpp" line_range="280" />
<code_context>
-    lockFront.call("ShowAuth", autoStartAuth);
+    // Fire and forget: LockFront reads Power1 back, so waiting for its reply
+    // from a key handler only risks the 25s D-Bus timeout.
+    lockFront.asyncCall("ShowAuth", autoStartAuth);
 }

</code_context>
<issue_to_address>
**Suspend can outrun locking**

When lockFront takes longer than 500 ms to handle the request, for example while busy starting or displaying the lock UI, `handleSystemSuspend()` waits a fixed 500 ms after `doLock(true)` and then suspends, but the async call provides no indication that LockFront handled `ShowAuth` or displayed the lock UI. A delayed request can therefore leave the session unlocked when the machine suspends.

Keep the suspend request gated on LockFront handling the lock request, or otherwise confirm the session is locked before suspending.
</issue_to_address>

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

1. The session D-Bus service file declared
   SystemdService=org.deepin.dde.Power1.service, but dde-services never
   shipped that unit, so journald showed "Unit ... not found" and dde-lock
   logged "read SleepLock property failed".
2. dde-lock's synchronous SleepLock read started a dedicated dsm instance
   whose power plugin synchronously introspected LockFront1/ShutdownFront1
   exported by dde-lock, causing a 25s mutual wait.
3. Activate Power1 through deepin-service-manager's shared plugin template,
   drop the unused dedicated unit, and replace the front DDBusInterface
   proxies with raw QDBusMessage calls so plugin startup no longer
   introspects dde-lock services.
4. TurnOffScreen blanked the screen only after doLock(true); it now calls
   setDPMSModeOff() first, and showLockAuth plus PowerController::doLock
   fire-and-forget ShowAuth so neither path blocks on LockFront's Power1
   readback.

Influence:
1. Reboot and check `journalctl -fp err`: no "Unit
   org.deepin.dde.Power1.service not found" and no "read SleepLock property
   failed".
2. Auto-login shows the lock screen immediately instead of the desktop for
   about 20s; pressing the power button blanks the display immediately with
   no 25s gap before "Setting DPMS mode to off".
3. Lock/unlock, suspend/resume, hibernate and shutdown still work; repeat
   screen-off after a resume and confirm it still blanks immediately.
4. `systemctl --user list-units | grep Power1` shows
   deepin-service-plugin@org.deepin.dde.Power1.service.

fix(power): 修正 Power1 激活方式并修复锁屏死锁

1. session 的 D-Bus 文件声明
   SystemdService=org.deepin.dde.Power1.service,但 dde-services 从未
   安装该 unit,journal 中出现 "Unit ... not found" 以及 dde-lock 的
   "read SleepLock property failed"。
2. dde-lock 同步读取 SleepLock 会拉起独立 dsm 实例,其 power 插件初始化
   时同步 introspect dde-lock 导出的 LockFront1/ShutdownFront1,双方互等
   25 秒。
3. 改用 deepin-service-manager 的共享插件模板激活 Power1,删除未使用的
   专用 unit,并把前端 DDBusInterface 改为原生 QDBusMessage 调用,启动时
   不再 introspect dde-lock 服务。
4. TurnOffScreen 原先在 doLock(true) 之后才关屏,现改为先
   setDPMSModeOff();showLockAuth 与 PowerController::doLock 均改为异步
   发送 ShowAuth,不再阻塞等待 LockFront 回读 Power1。

Influence:
1. 重启后检查 `journalctl -fp err`,不再出现
   "Unit org.deepin.dde.Power1.service not found" 和
   "read SleepLock property failed"。
2. 自动登录后锁屏立即出现,不再先显示桌面约 20 秒;按电源键显示器立即
   熄灭,"Setting DPMS mode to off" 前没有 25 秒间隔。
3. 锁屏/解锁、待机/唤醒、休眠、关机均正常;待机唤醒后再关屏仍立即熄灭。
4. `systemctl --user list-units | grep Power1` 显示
   deepin-service-plugin@org.deepin.dde.Power1.service。

Log: 修复 Power1 激活方式与锁屏死锁,并立即关闭显示器。
PMS: BUG-383573
@52cyb
52cyb force-pushed the fix/power-blank-stall-2500u2pajil branch from 3710e40 to 92b1466 Compare November 20, 2026 02:15
@52cyb 52cyb changed the title fix(power): avoid 25s stall when blanking the screen fix(power): activate Power1 via dsm and fix lock stall Nov 20, 2026
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 52cyb, mhduiy

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

@52cyb

52cyb commented Nov 20, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Nov 20, 2026

Copy link
Copy Markdown

This pr force merged! (status: unstable)

@deepin-bot
deepin-bot Bot merged commit 218fa56 into linuxdeepin:release/2500u2-pajil Nov 20, 2026
10 of 11 checks passed
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