Conversation
…ot when enqueued When notifications are sent rapidly (e.g. 0.2s interval), the 5-second timeout was calculated from the enqueue time rather than when the bubble actually appears on screen. Due to the 300ms throttle queue in BubbleModel, bubbles could still be pending when their timeout expired, causing the server close signal to be lost (removeById only checks shown bubbles, not the pending queue). This left bubbles permanently stuck on screen and broke the notification center's temporary display area. Fix by deferring pushPendingEntity until the bubble is actually shown: - Store expireTimeout in m_pendingExpireTimeouts at Notify() time - Add onBubbleShowed() to start the timeout when bubble appears - Emit bubbleShown signal from BubbleModel on insert/replace - Forward through BubblePanel → NotifyServerApplet → NotificationManager Closes: BUG-372279
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
Reviewer's GuideThe PR fixes premature notification expiration by deferring the server-managed timeout until the bubble is actually inserted or replaced on screen, using a new bubbleShown signal and callback chain from the bubble model through the panel and applet to NotificationManager. Sequence diagram for starting notification timeout after bubble is shownsequenceDiagram
participant BubbleModel
participant BubblePanel
participant NotifyServerApplet
participant NotificationManager
participant Persistence
BubbleModel->>BubblePanel: bubbleShown(id)
BubblePanel->>NotifyServerApplet: onBubbleShowed(id)
NotifyServerApplet->>NotificationManager: onBubbleShowed(id)
NotificationManager->>Persistence: fetchEntity(id)
Persistence-->>NotificationManager: NotifyEntity
NotificationManager->>NotificationManager: pushPendingEntity(entity, expireTimeout)
Note over NotificationManager: Timeout begins when bubble is shown
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto reviewAI 代码审查报告
总体评分
审查结论代码审查通过。本次 PR 修复了 BUG-372279(通知 bubble 超时计时起点错误),将超时计时从"服务端入列时刻"改为"bubble 实际上屏时刻",通过新增信号/槽转发链路实现。代码实现与 commit message 目的完全一致,信号流转链路清晰,错误处理完善,无安全漏洞。存在少量代码质量改进空间(缺少注释、命名不一致),但不影响功能正确性。 维度1:语法逻辑 (25/25) ✓
分析内容: 本次修改涉及 8 个文件,核心逻辑是将通知超时计时起点从
边界处理:
线程安全:
维度2:代码质量 (22/25) ✓
分析内容:
维度3:代码性能 (19/20) ✓
分析内容:
维度4:代码安全 (30/30) ✓
分析内容:
改进建议建议1:添加方法注释在 // notificationmanager.cpp - Notify() 方法中
// 0: never expire. -1: DefaultTimeOutMSecs
if (expireTimeout != 0 && !critical) {
// 暂存超时值,待 bubble 实际上屏后再启动计时
// 避免 bubble 在排队等待上屏期间超时已到期
m_pendingExpireTimeouts.insert(entity.id(), expireTimeout);
}// notificationmanager.cpp - onBubbleShowed() 方法
/**
* @brief bubble 实际上屏后的回调,启动超时计时
* @param id 通知 entity ID
*
* 从 m_pendingExpireTimeouts 取出暂存的超时值,
* 从持久层获取 entity 并启动超时计时。
* 此方法确保超时计时从 bubble 上屏时刻开始,而非入列时刻。
*/
void NotificationManager::onBubbleShowed(qint64 id)
{
// ... implementation
}建议2:统一命名将 // notificationmanager.h
Q_INVOKABLE void onBubbleShown(qint64 id); // 改为 onBubbleShown
// notifyserverapplet.h
void onBubbleShown(qint64 id); // 改为 onBubbleShown修改文件清单
|
|
#1691 再此跟踪 |
修复 BUG-372279:通知 bubble 超时计时起点错误
问题描述
以 0.2s 间隔连发 100 条通知时,桌面通知无法自动消失,通知中心暂驻区域无法显示通知。间隔 ≥0.3s 或注销/重启后恢复正常。
根因
通知 5 秒超时计时起点设在服务端入列时刻(
notificationmanager.cpp中point = now + interval),而非 bubble 实际上屏时刻。Bubble 上屏有 300ms 节流排队机制(bubblemodel.cpp),当以 0.2s 间隔连发通知时,约第 51 条起超时计时在 bubble 上屏前就已到期。超时到期时removeById只检查m_bubbles(已上屏列表),不覆盖pendingBubbles(待上屏队列),导致 close 信号丢失,bubble 永久卡在桌面。修复方案
采用产品确认的改法 2(根因层修复):将通知超时计时起点从"服务端入列时刻"改为"bubble 实际上屏时刻",服务端仍为唯一超时持有者。
改动文件(8 个文件):
notificationmanager.h/.cpp:Notify()中不再直接调用pushPendingEntity,改为将expireTimeout暂存到m_pendingExpireTimeouts;新增onBubbleShowed(qint64 id)按上屏回调启动计时;removePendingEntity()末尾清理暂存notifyserverapplet.h/.cpp:新增onBubbleShowed(qint64 id)槽,跨线程转发到 managerbubblemodel.h/.cpp:新增bubbleShown(qint64 id)信号,在insertBubble()和replaceBubble()末尾 emitbubblepanel.h/.cpp:init()中连接bubbleShown→onBubbleShown,通过QMetaObject::invokeMethod转发到 applet信号流转链路:
与 #1691 方案对比
存在关联 PR #1691(由 @Ivy233 创建,同样修复 BUG-372279,当前 OPEN)。两个方案解决同一根因,但实现路径不同:
NotificationManager(不变)ExpireTimer单例(新增)onBubbleShowed回调,bubble 上屏后回传服务端启动计时ExpireTimer单例两个方案各有优劣,供 reviewer 对比评估后决定合并方向。
PMS Bug
https://pms.uniontech.com/bug-view-372279.html
Summary by Sourcery
Start notification expiration timing when each bubble becomes visible to ensure queued notifications can be displayed and dismissed correctly.
Bug Fixes:
Enhancements: