fix: make upgrade delivery property reads async - #338
Conversation
1. Add asyncGetUploadLimitSpeed/asyncGetDownloadLimitSpeed to UpdateAssistant, issuing async org.freedesktop.DBus.Properties.Get calls instead of blocking synchronous property reads with 25s default timeout 2. Stop re-reading properties synchronously in onPropertyChanged, emit the new values carried by PropertiesChanged directly 3. Add refreshUpgradeDeliveryDownloadLimitSpeed/ refreshUpgradeDeliveryUploadLimitSpeed in UpdateWorker: fetch speed limit asynchronously via QDBusPendingCallWatcher, update model only when reply is valid and non-empty, keep current config and log a warning otherwise 4. Switch refreshUpgradeDeliveryInfo (activate path), the setUpgradeDeliveryEnabled success callback and the QML-invoked getUpgradeDeliveryXxxLimitSpeed to the async refresh helpers; public signatures unchanged so QML needs no adaptation Log: Make upgradedelivery limit-speed property reads asynchronous to avoid occasional 30s UI stalls when org.deepin.upgradedelivery responds slowly or hangs Influence: 1. Repeatedly enter update page, verify no long stall and limit speed values still display correctly via model NOTIFY bindings 2. Stop org.deepin.upgradedelivery service and enter page: UI must not block, warning is logged and current config is kept fix: 将升级传递属性读取改为异步避免界面卡顿 1. 在 UpdateAssistant 中新增 asyncGetUploadLimitSpeed/ asyncGetDownloadLimitSpeed,通过异步的 org.freedesktop.DBus.Properties.Get 调用替代默认超时 25 秒 的同步属性读取 2. onPropertyChanged 不再同步回读属性,直接使用 PropertiesChanged 信号携带的新值发出通知 3. 在 UpdateWorker 中新增 refreshUpgradeDeliveryDownloadLimitSpeed/ refreshUpgradeDeliveryUploadLimitSpeed:通过 QDBusPendingCallWatcher 异步获取限速配置,仅当返回有效且 非空时更新 model,否则保持当前配置并输出 warning 日志 4. 将 refreshUpgradeDeliveryInfo(activate 启动路径)、 setUpgradeDeliveryEnabled 成功回调以及 QML 调用的 getUpgradeDeliveryXxxLimitSpeed 切换到上述异步刷新方法; 对外接口签名不变,QML 无需适配 Log: 将升级传递限速属性的读取改为异步,避免 org.deepin.upgradedelivery 响应缓慢或无响应时界面偶发卡顿 30 秒的问题 Influence: 1. 反复进入更新页,验证不再出现长时间卡顿,且限速值通过 model NOTIFY 绑定正常显示 2. 停止 org.deepin.upgradedelivery 服务后进入页面:界面不得 阻塞、有 warning 日志、保持当前配置 PMS: BUG-372823
Reviewer's GuideUpgrade-delivery upload and download limit-speed reads now use asynchronous DBus calls throughout, eliminating potential 25-second UI stalls while preserving existing model values on failed or empty responses. Sequence diagram for asynchronous upgrade-delivery speed refreshsequenceDiagram
participant UI as QML UI
participant Worker as UpdateWorker
participant Assistant as UpdateAssistant
participant DBus as upgradedelivery DBus service
participant Model as Update model
UI->>Worker: getUpgradeDeliveryDownloadLimitSpeed()
Worker->>Assistant: asyncGetDownloadLimitSpeed()
Assistant->>DBus: Properties.Get(DownloadLimitSpeed)
DBus-->>Assistant: QDBusPendingReply
Assistant-->>Worker: QDBusPendingCallWatcher.finished
alt valid non-empty speed
Worker->>Model: setUpgradeDownloadSpeedLimitConfig()
Model-->>UI: NOTIFY updated value
else error or empty speed
Worker-->>Worker: qCWarning()
Worker->>Model: keep current configuration
end
Sequence diagram for direct PropertiesChanged speed notificationssequenceDiagram
participant DBus as upgradedelivery DBus service
participant Assistant as UpdateAssistant
participant Model as Update model
DBus-->>Assistant: PropertiesChanged(UploadLimitSpeed, DownloadLimitSpeed)
Assistant->>Assistant: onPropertyChanged()
Assistant-->>Model: UploadLimitSpeedChanged(new value)
Assistant-->>Model: DownloadLimitSpeedChanged(new value)
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/dcc-update-plugin/operation/updatework.cpp" line_range="1881" />
<code_context>
+ qCWarning(logDccUpdatePlugin) << "async get download limit speed is empty";
+ return;
+ }
+ m_model->setUpgradeDownloadSpeedLimitConfig(transferDeliveryConfigToLastoreDeliveryConfig(speed).toUtf8());
+ });
+}
</code_context>
<issue_to_address>
**issue (bug_risk):** The refresh callbacks accept any non-empty DBus string as valid and pass it to `transferDeliveryConfigToLastoreDeliveryConfig`; malformed or otherwise invalid JSON is converted into a default/empty configuration and overwrites the model instead of preserving the current configuration.
**Triggers:** When org.deepin.upgradedelivery returns a non-empty malformed or invalid limit-speed configuration.
**Suggested fix:** Validate `UpgradeSpeedLimitConfig::fromJson` successfully parsed the returned configuration before updating the model.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| qCWarning(logDccUpdatePlugin) << "async get download limit speed is empty"; | ||
| return; | ||
| } | ||
| m_model->setUpgradeDownloadSpeedLimitConfig(transferDeliveryConfigToLastoreDeliveryConfig(speed).toUtf8()); |
There was a problem hiding this comment.
issue (bug_risk): The refresh callbacks accept any non-empty DBus string as valid and pass it to transferDeliveryConfigToLastoreDeliveryConfig; malformed or otherwise invalid JSON is converted into a default/empty configuration and overwrites the model instead of preserving the current configuration.
Triggers: When org.deepin.upgradedelivery returns a non-empty malformed or invalid limit-speed configuration.
Suggested fix: Validate UpgradeSpeedLimitConfig::fromJson successfully parsed the returned configuration before updating the model.
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
📝 变更概述
变更目的: 将升级传递限速属性的读取改为异步,避免 🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过(23/25 分) 潜在问题:
建议: 建议在 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过(23/25 分) 潜在问题:
建议: 可考虑将两个 refresh 方法合并为一个通用方法,通过参数区分上传/下载方向,减少代码重复。但考虑到仅 2 个方法且逻辑清晰,当前重复程度可接受。 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过(20/20 分) 潜在问题: 建议: 本次变更的核心目标就是性能优化:将同步 DBus 属性读取(25 秒超时)替换为异步读取,有效避免 UI 线程阻塞。 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过(30/30 分)
安全漏洞详情: 漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个 建议: 本次变更未引入安全漏洞。 💡 改进建议代码示例// 建议在 refresh 方法中增加空指针检查:
void UpdateWorker::refreshUpgradeDeliveryDownloadLimitSpeed()
{
if (!m_updateAssistant) {
qCWarning(logDccUpdatePlugin) << "m_updateAssistant is null, skip refresh download limit speed";
return;
}
auto watcher = new QDBusPendingCallWatcher(m_updateAssistant->asyncGetDownloadLimitSpeed(), this);
// ... 其余逻辑不变
}📋 审查检查清单
本报告由 AI 代码审查工具自动生成 | 扫描时间: 2026-08-28 09:18:00 |
|
TAG Bot New tag: 1.0.62 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: caixr23, xionglinlin 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 |
Log: Make upgradedelivery limit-speed property reads asynchronous to avoid occasional 30s UI stalls when
org.deepin.upgradedelivery responds slowly or hangs
Influence:
fix: 将升级传递属性读取改为异步避免界面卡顿
Log: 将升级传递限速属性的读取改为异步,避免
org.deepin.upgradedelivery 响应缓慢或无响应时界面偶发卡顿
30 秒的问题
Influence:
PMS: BUG-372823
Summary by Sourcery
Make upgrade delivery speed-limit reads asynchronous to prevent UI stalls and safely retain current settings when the service cannot provide valid values.
Bug Fixes:
Enhancements: