Skip to content

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

Open
52cyb wants to merge 1 commit into
linuxdeepin:masterfrom
52cyb:master
Open

52cyb wants to merge 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, 1s bounded ShowAuth) so power plugin startup no longer resolves or introspects dde-lock services.
  5. Add a private-bus regression test whose fixture exports the front services without dispatching, asserting power proxy calls do not block.

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; run ctest power-lockfront-proxy and power-screensaver-proxy.
  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 最多等 1s),使 power 插件启动时不再解析/introspect dde-lock 的服务。
  5. 新增私有总线回归测试:fixture 导出前端服务但不处理消息,断言 power 代理调用不再阻塞。

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

Influence:

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

PMS: BUG-351573

Summary by Sourcery

Activate the session Power1 service consistently and eliminate the startup deadlock between the power plugin and dde-lock front ends.

Bug Fixes:

  • Fix Power1 activation so the session service is provided through the shared deepin-service-manager plugin template.
  • Prevent dde-lock and the power plugin from deadlocking during startup when communicating with front-end D-Bus services.

Enhancements:

  • Use non-introspecting D-Bus calls for suspend, hibernate, shutdown, authentication, and black-screen operations to keep power startup responsive while preserving a bounded authentication wait.

Tests:

  • Add regression coverage verifying power proxy calls do not block when front-end D-Bus services are exported but unable to process requests.

Chores:

  • Remove the unused dedicated Power1 systemd unit.

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, 1s bounded ShowAuth) so power plugin startup no
   longer resolves or introspects dde-lock services.
5. Add a private-bus regression test whose fixture exports the front
   services without dispatching, asserting power proxy calls do not block.

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;
   run ctest power-lockfront-proxy and power-screensaver-proxy.
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 最多等 1s),使 power 插件启动时不再解析/introspect
   dde-lock 的服务。
5. 新增私有总线回归测试:fixture 导出前端服务但不处理消息,断言
   power 代理调用不再阻塞。

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

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

PMS: BUG-351573
@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 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-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交修复了 D-Bus 通信中的死锁问题,通过将 DDBusInterface 调用替换为原始 QDBusMessage 调用避免了阻塞式 Introspect 导致的死锁。同时将 Power1 服务改为通过 dsm 模板激活,删除了独立的 systemd 服务文件。代码逻辑正确,注释完善,无安全漏洞,仅存在少量代码重复。

🔍 详细分析

1. 语法逻辑 ✅

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

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

建议: ['无需修改,语法逻辑正确']


2. 代码质量 ✅

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

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

建议: ['建议将 requestSuspendByFront/requestHibernateByFront/requestShutdownByFront 提取为带方法名参数的辅助函数,例如:void SessionDBusProxy::callShutdownFrontMethod(const QString &method) { QDBusConnection::sessionBus().asyncCall(QDBusMessage::createMethodCall(kShutdownFront, kShutdownPath, kShutdownFront, method)); }']


3. 代码性能 ✅

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

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

建议: ['无需修改,性能表现良好']


4. 代码安全 🔒

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

🔐 发现 0 个安全漏洞

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

建议: ['无需修改,无安全风险']


💡 改进建议代码示例

// 建议提取公共辅助函数,减少三个方法中的代码重复:
void SessionDBusProxy::callShutdownFrontMethod(const QString &method)
{
    QDBusConnection::sessionBus().asyncCall(QDBusMessage::createMethodCall(
        kShutdownFront, kShutdownPath, kShutdownFront, method));
}

void SessionDBusProxy::requestSuspendByFront()
{
    callShutdownFrontMethod(QStringLiteral("Suspend"));
}

void SessionDBusProxy::requestHibernateByFront()
{
    callShutdownFrontMethod(QStringLiteral("Hibernate"));
}

void SessionDBusProxy::requestShutdownByFront()
{
    callShutdownFrontMethod(QStringLiteral("Shutdown"));
}

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

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.

2 participants