Repository navigation
fix: prevent tray startup stalls and follow the dock lifecycle - #523
Conversation
Reviewer's GuideThe PR separates group resolution from GUI startup, asynchronously initializes tray plugins with controlled environment restoration, and introduces a dock-bound readiness gate so tray startup follows the correct dock generation while teardown remains parallel. It also adds build-tree/cache-isolated CTest coverage and a manual systemd lifecycle test suite for startup, restart, failure, recovery, and shutdown behavior. Sequence diagram for asynchronous tray plugin initializationsequenceDiagram
participant Loader as trayplugin-loader
participant Manager as PluginManager
participant Plugin as TrayPlugin
participant EventLoop as QtEventLoop
Loader->>Manager: loadPlugins()
Manager->>EventLoop: QTimer.singleShot(0, loadNextPlugin)
EventLoop->>Manager: loadNextPlugin()
Manager->>Loader: pluginLoadStarted()
Loader->>Manager: applyEnvs(pluginEnvs)
Manager->>Plugin: loadPlugin(pluginPath)
Plugin-->>Manager: plugin initialized
Manager->>Loader: pluginLoadFinished()
Loader->>Manager: applyEnvs(oldEnvs)
Manager->>EventLoop: QTimer.singleShot(0, loadNextPlugin)
Manager-->>Loader: loadingFinished(success)
Sequence diagram for group launcher and dock-bound tray readinesssequenceDiagram
participant Systemd as systemd
participant GroupLoader as trayplugin-group-loader
participant Loader as trayplugin-loader
participant Ready as dde-tray-loader-ready.service
participant Dock as Dock
Systemd->>GroupLoader: start group target
GroupLoader->>GroupLoader: pluginPathsForGroup(group)
alt group is empty
GroupLoader-->>Systemd: exit 0 without GUI initialization
else group has plugins
GroupLoader->>Loader: execl(trayplugin-loader, paths, group)
Systemd->>Ready: start after dock startup/restart
Ready->>Dock: readiness check
alt dock is ready
Ready-->>Systemd: readiness succeeded
Systemd->>Loader: activate tray target
else readiness fails
Ready-->>Systemd: readiness failed
Systemd-->>Loader: block tray startup
end
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
e4dac92 to
98565ab
Compare
19b075b to
b6bb666
Compare
deepin pr auto reviewAI 代码审查报告
总体评价
本次 PR 修复了托盘启动卡顿问题,将插件加载从同步改为异步(通过 QTimer::singleShot 在插件之间返回事件循环),将电源属性读取从同步 DBus 调用改为异步缓存模式(使用 QDBusPendingCallWatcher 和 m_liveProperties 集合管理属性一致性),并通过 systemd 单元文件将托盘生命周期绑定到 Dock。代码结构清晰,注释充分,测试覆盖全面,无安全漏洞。 漏洞统计
漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个 四维度评分维度1:语法逻辑 ✓ — 25/25
维度2:代码质量 ✓ — 24/25
维度3:代码性能 ✓ — 20/20
维度4:代码安全 ✓ — 30/30
改进建议
代码目的匹配度本次 PR 的目的是修复托盘启动卡顿并绑定 Dock 生命周期,代码实现与目的完全一致:
审查结论本次代码变更质量优秀,异步加载和异步属性缓存的实现逻辑正确,注释充分,测试覆盖全面,无安全漏洞。建议合并。 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: robertkill, 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 |
Resolve each plugin group once in the existing loader and yield to the GUI event loop between plugin initializations, restoring the session environment for callbacks. Fetch session power properties asynchronously and serve cached values so a slow power service cannot block the group. Handle GetAll replies separately from live notifications, preserving properties updated in flight and refreshing invalidated properties after the pending request. Discard old requests when the service owner changes. Retry failed snapshots asynchronously after one second. Cover cache ordering and recovery with a manual isolated D-Bus integration test. Bind the tray target to the Dock with BindsTo, PartOf and After. Wait for the replacement Type=dbus Dock on restart; stop tray groups in parallel before the Dock. No extra launcher or readiness service is needed. Add isolated event-dispatch and manual systemd lifecycle tests, startup timing logs, and documentation of the final lifecycle. 在现有 loader 中仅解析一次插件分组,在插件初始化之间返回 GUI 事件循环, 并为回调恢复会话环境。异步获取会话电源属性并提供缓存读取,避免电源服务 响应缓慢时阻塞整个分组。单独处理 GetAll 回复,保留请求期间的实时属性更新, 并在当前请求结束后重新获取失效属性。服务拥有者变化时丢弃旧请求,快照失败后 间隔一秒异步重试,通过手动隔离 D-Bus 集成测试验证缓存时序与失败恢复。 托盘 target 通过 BindsTo、PartOf 和 After 绑定 Dock,重启时等待替换后的 Type=dbus Dock;退出时各托盘组并行停止,再停止 Dock。无需额外启动器或 就绪服务。增加隔离的事件分发测试、手动 systemd 生命周期测试、初始化耗时 日志,并记录最终生命周期。 Log: prevent tray startup stalls and follow the dock lifecycle Pms: BUG-378589
b6bb666 to
6aa0479
Compare
|
/forcemerge |
|
This pr force merged! (status: blocked) |
Slow initialization or synchronous power-property reads can hold a tray group's GUI thread and delay other plugin icons. Yield to the event loop between plugin initializations, restore the session environment for callbacks, and fetch session power properties asynchronously into a cache. Process
GetAllreplies separately from DTK's live notifications: keep properties updated while a snapshot is pending, fill the remaining properties from the snapshot, and coalesce in-flight invalidations into a follow-up request. Discard pending requests when the service owner changes. Retry failed snapshots after one second without blocking the GUI thread. Retain initialization timing logs to distinguish plugin work from group startup.Start the existing loader directly with
--group, resolving membership once. The tray target usesBindsTo=,PartOf=andAfter=dde-shell@DDE.service, waiting for the Dock's Type=dbus startup/restart job before launching groups. The Dock registers its bus name after its internal compositor is ready. There is no additional launcher or readiness service. Tray groups stop in parallel before the Dock; desktop/Dock ordering remains independent.插件之间返回事件循环,电源属性改为异步缓存读取,避免慢插件或慢电源服务拖住同组图标。托盘直接绑定 Dock 的生命周期并等待其启动完成,删除 ready 服务;保留现有 loader,退出时各组并行停止后再停止 Dock,桌面与 Dock 保持独立。
Validation
CMAKE_SKIP_BUILD_RPATH=ONpassed.HOME=/nonexistentand no inheritedXDG_CACHE_HOME; the test supplies its own cache and build-tree interface library.NoReplyfailures while the service keeps its name and only percentage updates arrive. The prior code fails to restore the missing state; the patched code restores all cached properties, keeps dispatching events, and stops retries after success/destruction. The isolated bus was stopped after the test. The test executable is excluded from the default build and is not installed or run by package CTest.Initialization completion does not measure the first visible frame. One intermittent gap between plugins remains unrooted; this PR fixes the confirmed blocking paths rather than claiming every startup delay is resolved. A slow tray can still delay Dock shutdown through the required ordering.
Paired session change: linuxdeepin/dde-session#234
Pms: BUG-378589