Repository navigation
fix(power): avoid 25s stall when blanking the screen - #217
Conversation
Reviewer's GuideUses of the APISend LockFront ShowAuth asynchronously in both power paths so waiting for its reply cannot block the caller.
ImplementationBlank the display before requesting the lock so the lock operation cannot delay DPMS shutdown.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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/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>
**Session resumes unlocked**
When lockFront does not process the request within the fixed 500 ms pause, `handleSystemSuspend()` calls `systemSuspend()` without confirming `ShowAuth` completed, so the machine suspends before the session is locked and resumes to an unlocked session.
Wait for confirmation that `ShowAuth` has completed before calling `systemSuspend()`.
</issue_to_address>
### Comment 2
<location path="src/plugin-qt/power/session/powermanager.cpp" line_range="639-641" />
<code_context>
+ // Blank first: locking goes through LockFront, which reads Power1 back, so
+ // it must never gate how long the display stays lit.
setDPMSModeOff();
+ if (m_screenBlackLock)
+ doLock(true);
SetPrepareSuspend(PS_Finish);
</code_context>
<issue_to_address>
**Wake can precede locking**
When the user presses the power button again while LockFront has not yet processed the first asynchronous lock request, `TurnOffScreen()` blanks the display before the asynchronous lock request takes effect. A second power-button press sees the display off and turns it back on, exposing the still-unlocked session until LockFront handles the pending request.
Track the pending lock and prevent waking the display until the session is locked, or otherwise ensure the lock takes effect before exposing the screen.
</issue_to_address>| 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); |
There was a problem hiding this comment.
🟠 High · Session resumes unlocked
When lockFront does not process the request within the fixed 500 ms pause, handleSystemSuspend() calls systemSuspend() without confirming ShowAuth completed, so the machine suspends before the session is locked and resumes to an unlocked session.
Wait for confirmation that ShowAuth has completed before calling systemSuspend().
Prompt for AI agents
In `src/plugin-qt/shortcut/tools/dde-shortcut-tool/powercontroller.cpp` at line 280:
**Session resumes unlocked**
When lockFront does not process the request within the fixed 500 ms pause, `handleSystemSuspend()` calls `systemSuspend()` without confirming `ShowAuth` completed, so the machine suspends before the session is locked and resumes to an unlocked session.
Wait for confirmation that `ShowAuth` has completed before calling `systemSuspend()`.4a4e884 to
efa7382
Compare
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: fly602, mhduiy The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
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-382691
efa7382 to
308d430
Compare
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: [] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: [] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例// 当前实现已为正确做法,无需修改。建议保持:
// sessiondbusproxy.cpp - 异步调用避免阻塞主线程
void SessionDBusProxy::showLockAuth(bool autoStart)
{
QDBusMessage msg = QDBusMessage::createMethodCall(
kLockFront, kLockFrontPath, kLockFront, QStringLiteral("ShowAuth"));
msg << autoStart;
QDBusConnection::sessionBus().asyncCall(msg);
}
// powercontroller.cpp - fire and forget
lockFront.asyncCall("ShowAuth", autoStartAuth);
// powermanager.cpp - 先息屏再上锁,避免 LockFront 同步读取 Power1 阻塞息屏
setDPMSModeOff();
if (m_screenBlackLock)
doLock(true);本报告由 AI 代码审查工具自动生成 |
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Bug: https://pms.uniontech.com/bug-view-382691.html
fix(power): avoid 25s stall when blanking the screen
SleepLock back, so both sides stalled until the 25s D-Bus timeout and
the display stayed lit the whole time.
X11 turn-off path blanks the screen before requesting the lock.
so the power-button shortcut no longer blocks its key handler.
Log: Blank the screen immediately instead of waiting for LockFront.
Influence:
no 25s gap between "Locking session" and "Setting DPMS mode to off".
still blanks immediately.
fix(power): 修复锁屏回读导致关屏延迟 25 秒
中回读 Power1 SleepLock,双方互等到 25 秒 D-Bus 超时,期间屏幕
一直亮着。
X11 关屏路径先关闭显示器再请求锁屏。
不再阻塞快捷键处理。
Log: 立即关闭显示器,不再等待 LockFront 返回。
Influence:
"Setting DPMS mode to off" 不再有 25 秒间隔。
PMS: BUG-382691
Summary by Sourcery
Avoid power-button screen-off delays by blanking the display immediately and making lock-authentication requests asynchronous.
Bug Fixes:
Enhancements: