fix: delay authentication creation after system wake - #82
Conversation
1. Add a dedicated `m_wakeUpAuthTimer` (300ms single-shot) to postpone authentication creation after system wake-up 2. Replace direct `createAuthentication()` calls in system wake and active change flows with timer-triggered execution 3. Stop timer appropriately during sleep, invisible, or inactive states to prevent unnecessary authentication 4. Fix potential race condition where authentication creation during screen wake could be interrupted by system events Log: Fix potential lock screen flash or authentication failure after system wake-up Influence: 1. Test system wake-up from sleep and verify lock screen appears normally without flashing 2. Test rapid wake-sleep-wake cycles to ensure authentication state is consistent 3. Test when lock screen is invisible during wake-up to verify no authentication is created 4. Test switching user accounts after wake-up to verify authentication creation is correct 5. Test system suspend/resume multiple times to check stability 6. Verify no authentication is triggered when system enters sleep or becomes inactive fix: 延迟系统唤醒后的认证创建 1. 添加专用的 `m_wakeUpAuthTimer`(300ms 单次触发)来延迟系统唤醒后的认 证创建 2. 将系统唤醒和活动状态变化流程中的直接 `createAuthentication()` 调用替 换为定时器触发执行 3. 在休眠、不可见或不活动状态时适当停止定时器,避免不必要的认证 4. 修复屏幕唤醒期间认证创建可能被系统事件打断的竞态条件问题 Log: 修复系统唤醒后可能出现的锁屏闪烁或认证失败问题 Influence: 1. 测试系统从休眠唤醒后锁屏是否正常显示,无闪烁现象 2. 测试快速唤醒-休眠-唤醒循环,验证认证状态一致性 3. 测试唤醒时锁屏不可见的情况,验证不会创建认证 4. 测试唤醒后切换用户账户,验证认证创建正确性 5. 多次测试系统挂起/恢复,检查稳定性 6. 验证系统进入休眠或不活动状态时不会触发认证 PMS: BUG-373405
Reviewer's guide (collapsed on small PRs)Reviewer's GuideIntroduces a 300 ms single-shot delay for authentication creation during system wake and active-state changes, while cancelling pending work in sleep, invisible, and inactive paths to reduce wake-up races, lock-screen flashing, and authentication failures. Sequence diagram for delayed wake-up authenticationsequenceDiagram
participant System
participant LockWorker
participant WakeUpAuthTimer
participant Authentication
System->>LockWorker: activeChanged(active)
alt active and visible
LockWorker->>WakeUpAuthTimer: start()
WakeUpAuthTimer-->>LockWorker: timeout after 300 ms
LockWorker->>Authentication: createAuthentication(name)
else inactive or invisible
LockWorker->>WakeUpAuthTimer: stop()
LockWorker->>Authentication: endAuthentication(account, AT_All)
LockWorker->>Authentication: destroyAuthentication(account)
end
System->>LockWorker: systemStateChanged(isSleep)
alt entering sleep
LockWorker->>WakeUpAuthTimer: stop()
else waking with active session
LockWorker->>WakeUpAuthTimer: start()
WakeUpAuthTimer-->>LockWorker: timeout after 300 ms
LockWorker->>Authentication: createAuthentication(name)
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/dde-lock/lockworker.cpp" line_range="223" />
<code_context>
if (active && m_model->visible()) {
- createAuthentication(m_model->currentUser()->name());
+ m_wakeUpAuthTimer->start();
} else {
+ m_wakeUpAuthTimer->stop();
</code_context>
<issue_to_address>
**issue (broader_impact):** The wake-up timer is started when the session is locked without checking that the lock screen is visible, and its timeout unconditionally calls `createAuthentication()`. If the lock screen becomes or remains invisible during the 300 ms delay, authentication is still created and `createAuthentication()` sets the session locked, causing unnecessary authentication and potentially reproducing the lock-screen flash this change is intended to prevent.
**Triggers:** When the system resumes while the session is locked but the lock screen is invisible, or when visibility changes to false before the timer expires.
**Suggested fix:** Stop the timer from the `visibleChanged(false)` path and re-check visibility, session activity, and the current lock state in the timeout callback before creating authentication.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 优秀 ✅ 通过 潜在问题:
建议: 在 lambda 中增加 nullptr 检查:if (m_model && m_model->currentUser()) { createAuthentication(m_model->currentUser()->name()); } 2. 代码质量 ✅评价: 优秀 ✅ 通过 潜在问题:
建议: 添加注释说明 300ms 延迟的设计依据和定时器用途,便于后续维护 3. 代码性能 ✅评价: 优秀 ✅ 通过 潜在问题:
建议: 定义命名常量:static constexpr int kWakeUpAuthDelayMs = 300; 4. 代码安全 🔒评价: 优秀 ✅ 通过
安全漏洞详情: 建议: 无需安全加固,代码变更不涉及安全风险 💡 改进建议代码示例// 在定时器 lambda 中增加 nullptr 检查
connect(m_wakeUpAuthTimer, &QTimer::timeout, this, [this](){
if (m_model && m_model->currentUser()) {
createAuthentication(m_model->currentUser()->name());
}
});
// 定义命名常量替代魔法数字
static constexpr int kWakeUpAuthDelayMs = 300;
m_wakeUpAuthTimer->setInterval(kWakeUpAuthDelayMs);本报告由 AI 代码审查工具自动生成 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 52cyb, yixinshark 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 |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
m_wakeUpAuthTimer(300ms single-shot) to postpone authentication creation after system wake-upcreateAuthentication()calls in system wake and active change flows with timer-triggered executionLog: Fix potential lock screen flash or authentication failure after system wake-up
Influence:
fix: 延迟系统唤醒后的认证创建
m_wakeUpAuthTimer(300ms 单次触发)来延迟系统唤醒后的认 证创建createAuthentication()调用替 换为定时器触发执行Log: 修复系统唤醒后可能出现的锁屏闪烁或认证失败问题
Influence:
PMS: BUG-373405
Summary by Sourcery
Delay post-wake authentication creation to stabilize lock-screen behavior during system power and session state transitions.
Bug Fixes:
Enhancements: