Skip to content

fix: activate Power1 via dsm template and fix deadlock - #204

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
52cyb:master
Nov 3, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
52cyb:master

Conversation

@52cyb

@52cyb 52cyb commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor
  1. The session D-Bus file declared
    SystemdService=org.deepin.dde.Power1.service, but dde-services never
    shipped that unit, so journald showed "Unit ... not found" and
    "read SleepLock property failed" from dde-lock.
  2. After making the unit available, dde-lock's synchronous SleepLock call
    started a dedicated dsm instance whose power plugin synchronously
    introspected LockFront1/ShutdownFront1 exported by dde-lock, causing a
    25s mutual wait: the desktop appeared first and the lock screen came
    back about 20s later.
  3. Activate Power1 through deepin-service-manager's shared plugin template
    and drop the unused dedicated unit, matching the system-level service.
  4. Replace the three front DDBusInterface proxies with raw QDBusMessage
    calls (async commands, synchronous ShowAuth with the default timeout)
    so power plugin startup no longer resolves or introspects dde-lock
    services.

Log: Fix Power1 activation and dde-lock power startup deadlock.

Influence:

  1. Reboot and check journalctl -fp err: no "Unit
    org.deepin.dde.Power1.service not found" or "read SleepLock property
    failed".
  2. Verify auto-login shows the lock screen immediately, not the desktop
    for about 20 seconds and then the login UI.
  3. Verify lock/unlock, suspend/resume, hibernate and shutdown still work.
  4. Check systemctl --user list-units | grep Power1 shows
    deepin-service-plugin@org.deepin.dde.Power1.service.

fix: 修正 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. 补上 unit 后,dde-lock 同步读取 SleepLock 会拉起独立 dsm 实例;其
    power 插件在初始化时同步 introspect dde-lock 导出的
    LockFront1/ShutdownFront1,双方互等 25s,桌面先显示、锁屏约 20s
    后才出现,表现为"自动回到登录界面"。
  3. 改用 deepin-service-manager 的共享插件模板激活 Power1,删除未使用
    的专用 unit,与系统级服务保持一致。
  4. 把三个前端 DDBusInterface 改为原生 QDBusMessage 调用(命令异步、
    ShowAuth 保持同步调用和默认超时),使 power 插件启动时不再
    解析/introspect dde-lock 的服务。

Log: 修复 Power1 激活方式以及 dde-lock 与电源服务的启动死锁。

Influence:

  1. 重启后检查 journalctl -fp err,不再出现
    "Unit org.deepin.dde.Power1.service not found" 和
    "read SleepLock property failed"。
  2. 验证自动登录后锁屏立即出现,不再先显示桌面约 20s 再回到登录界面。
  3. 验证锁屏/解锁、待机/唤醒、休眠、关机均正常。
  4. 检查 systemctl --user list-units | grep Power1 显示
    deepin-service-plugin@org.deepin.dde.Power1.service。

PMS: BUG-351573

Summary by Sourcery

Activate the Power1 service through the shared plugin infrastructure and eliminate the startup deadlock with dde-lock.

Bug Fixes:

  • Fix Power1 session service activation so the declared D-Bus service is provided by the shared deepin-service-manager plugin template.
  • Prevent dde-lock and the power plugin from deadlocking during startup by avoiding blocking interface introspection for front-end power, lock-authentication, and black-screen calls.

Enhancements:

  • Preserve synchronous lock-authentication behavior while making front-end power commands asynchronous and direct over D-Bus.

Chores:

  • Remove the unused dedicated Power1 service unit.

@sourcery-ai

sourcery-ai Bot commented Oct 26, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The PR fixes Power1 activation by using the shared service-manager plugin template and removes the startup deadlock by replacing front-end D-Bus interface proxies—which synchronously introspect dde-lock services—with raw message calls, asynchronous commands, and a one-second ShowAuth timeout.

Sequence diagram for non-blocking Power1 front-end calls

sequenceDiagram
    participant Power as PowerPlugin
    participant Proxy as SessionDBusProxy
    participant Bus as SessionBus
    participant Front as dde-lock FrontServices

    Power->>Proxy: requestSuspendByFront()
    Proxy->>Bus: asyncCall(Suspend)
    Bus-->>Proxy: queued
    Power->>Proxy: showLockAuth(autoStart)
    Proxy->>Bus: call(ShowAuth, Block, 1000)
    Bus-->>Proxy: reply or timeout
    Power->>Proxy: setBlackScreenActive(active)
    Proxy->>Bus: asyncCall(setActive)
    Bus-->>Proxy: queued
    Note over Proxy,Front: Raw QDBusMessage calls avoid blocking introspection
Loading

File-Level Changes

Change Details Files
Activate the session Power1 service through the shared deepin-service-manager plugin template instead of a dedicated unit.
  • Update the D-Bus service activation configuration to target the shared plugin service.
  • Remove the unused standalone Power1 systemd unit.
src/plugin-qt/power/session/misc/dbus/org.deepin.dde.Power1.service
src/plugin-qt/power/session/misc/org.deepin.dde.Power1.service
Eliminate startup deadlocks caused by front-end D-Bus proxy introspection.
  • Replace shutdown, lock-auth, and black-screen DDBusInterface proxies with raw QDBusMessage calls.
  • Make suspend, hibernate, shutdown, and black-screen commands asynchronous.
  • Bound ShowAuth's synchronous wait to one second and log failures.
src/plugin-qt/power/session/sessiondbusproxy.cpp
src/plugin-qt/power/session/sessiondbusproxy.h

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 reviewed your changes and they look great!


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

@deepin-bot

deepin-bot Bot commented Oct 29, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 1.0.48
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #208

@deepin-bot

deepin-bot Bot commented Oct 30, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 1.0.49
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #210

@deepin-bot

deepin-bot Bot commented Oct 30, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 1.0.50
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #213

@52cyb
52cyb force-pushed the master branch 3 times, most recently from 4cf3912 to 6894e07 Compare November 3, 2026 02:57
@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 99 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本提交通过 D-Bus 原始消息(QDBusMessage)替代 DDBusInterface 调用,解决了前端繁忙时阻塞式 Introspect 导致死锁的问题,同时将 Power1 服务改为 deepin-service-manager 模板激活方式。 四维度均通过,无安全漏洞,代码质量高,性能有所改善。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: [{'建议': '在 showLockAuth 和 setBlackScreenActive 中也添加类似注释,说明使用原始消息是为了避免 DDBusInterface 的阻塞式 Introspect 调用导致的死锁'}]


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: []


💡 改进建议代码示例

// 建议:在 showLockAuth 和 setBlackScreenActive 中补充注释,保持一致性

void SessionDBusProxy::showLockAuth(bool autoStart)
{
    // Raw messages only: avoid blocking Introspect from DDBusInterface.
    QDBusMessage msg = QDBusMessage::createMethodCall(
        kLockFront, kLockFrontPath, kLockFront, QStringLiteral("ShowAuth"));
    msg << autoStart;
    QDBusConnection::sessionBus().call(msg, QDBus::Block);
}

void SessionDBusProxy::setBlackScreenActive(bool active)
{
    // Raw messages only: avoid blocking Introspect from DDBusInterface.
    QDBusMessage msg = QDBusMessage::createMethodCall(
        kBlackScreen, kBlackScreenPath, kBlackScreen, QStringLiteral("setActive"));
    msg << active;
    QDBusConnection::sessionBus().asyncCall(msg);

    QDBusInterface kwin(QStringLiteral("org.kde.KWin"), QStringLiteral("/BlackScreen"),
                        QStringLiteral("org.kde.kwin.BlackScreen"),
                        QDBusConnection::sessionBus());
}

本报告由 AI 代码审查工具自动生成

@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

1. The session D-Bus file declared
   SystemdService=org.deepin.dde.Power1.service, but dde-services never
   shipped that unit, so journald showed "Unit ... not found" and
   "read SleepLock property failed" from dde-lock.
2. After making the unit available, dde-lock's synchronous SleepLock call
   started a dedicated dsm instance whose power plugin synchronously
   introspected LockFront1/ShutdownFront1 exported by dde-lock, causing a
   25s mutual wait: the desktop appeared first and the lock screen came
   back about 20s later.
3. Activate Power1 through deepin-service-manager's shared plugin template
   and drop the unused dedicated unit, matching the system-level service.
4. Replace the three front DDBusInterface proxies with raw QDBusMessage
   calls (async commands, synchronous ShowAuth with the default timeout)
   so power plugin startup no longer resolves or introspects dde-lock
   services.

Log: Fix Power1 activation and dde-lock power startup deadlock.

Influence:
1. Reboot and check `journalctl -fp err`: no "Unit
   org.deepin.dde.Power1.service not found" or "read SleepLock property
   failed".
2. Verify auto-login shows the lock screen immediately, not the desktop
   for about 20 seconds and then the login UI.
3. Verify lock/unlock, suspend/resume, hibernate and shutdown still work.
4. Check `systemctl --user list-units | grep Power1` shows
   deepin-service-plugin@org.deepin.dde.Power1.service.

fix: 修正 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. 补上 unit 后,dde-lock 同步读取 SleepLock 会拉起独立 dsm 实例;其
   power 插件在初始化时同步 introspect dde-lock 导出的
   LockFront1/ShutdownFront1,双方互等 25s,桌面先显示、锁屏约 20s
   后才出现,表现为"自动回到登录界面"。
3. 改用 deepin-service-manager 的共享插件模板激活 Power1,删除未使用
   的专用 unit,与系统级服务保持一致。
4. 把三个前端 DDBusInterface 改为原生 QDBusMessage 调用(命令异步、
   ShowAuth 保持同步调用和默认超时),使 power 插件启动时不再
   解析/introspect dde-lock 的服务。

Log: 修复 Power1 激活方式以及 dde-lock 与电源服务的启动死锁。

Influence:
1. 重启后检查 `journalctl -fp err`,不再出现
   "Unit org.deepin.dde.Power1.service not found" 和
   "read SleepLock property failed"。
2. 验证自动登录后锁屏立即出现,不再先显示桌面约 20s 再回到登录界面。
3. 验证锁屏/解锁、待机/唤醒、休眠、关机均正常。
4. 检查 `systemctl --user list-units | grep Power1` 显示
   deepin-service-plugin@org.deepin.dde.Power1.service。

PMS: BUG-351573
@52cyb

52cyb commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Nov 3, 2026

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot
deepin-bot Bot merged commit 25bc9eb into linuxdeepin:master Nov 3, 2026
5 of 6 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