Skip to content

fix(appmgr): revert theme icon defer to fix slow app loading - #809

Closed
mhduiy wants to merge 1 commit into
linuxdeepin:masterfrom
mhduiy:agent/pms-bug-bot/dcd91e0f5ab0
Closed

mhduiy wants to merge 1 commit into
linuxdeepin:masterfrom
mhduiy:agent/pms-bug-bot/dcd91e0f5ab0

Conversation

@mhduiy

@mhduiy mhduiy commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Root Cause Analysis

Commit 521429e ("fix(appmgr): defer apps until theme icon resolves") extended waitForIcon() to also defer apps whose theme-name icon QIcon::fromTheme() cannot resolve at startup. When the icon theme is not yet fully initialized during launcher startup, a large number of apps get queued and released only every 3 seconds (up to 120s timeout), causing visible slow/progressive app loading in windowed launcher mode.

Key evidence: appmgr.cpp:230-231 — the QIcon::fromTheme(iconName).isNull() check on theme icon names was added by 521429e; appsmodel.cpp:48-56 — DFileWatcherManager already monitors icon-theme.cache changes and triggers updateIconData() to refresh icons, making the deferral unnecessary.

Fix

Revert the theme-icon deferral logic introduced in commit 521429e. waitForIcon() now only defers apps with absolute-path icons whose file does not exist yet (original bug-347859 behavior). checkPendingAppItems() only checks QFileInfo::exists() and no longer calls IconUtils::tryUpdateIconCache(). Timeout restored from 40 (120s) to 20 (60s). The #include "iconutils.h" and #include <QIcon> headers removed as they were only used by the reverted code. Theme icons that become available after startup are handled by the existing DFileWatcherManager + updateIconData() mechanism.

Change Safety Assessment

Code Safety

  • Risk Level: Low
  • The reverted code was introduced by commit 521429e (2026-08-11) for BUG-371833; this change is a symmetric revert to the pre-521429e behavior which was already verified. The original bug-347859 fix (absolute-path icon deferral) is preserved unchanged.
  • BUG-371833 (null theme icons) remains covered by the existing DFileWatcherManager + updateIconData() mechanism, which predates 521429e. The highest-risk caller AppsModel::shouldDelaySourceIndex() logic is unchanged — only the deferral condition narrows.

Business Impact Scope

Affected module: launcher app list display in windowed mode. After the fix, all apps appear immediately on launcher startup instead of loading progressively. Theme icons that become available after startup are still refreshed via the icon cache watch mechanism. Absolute-path icons that don't exist yet are still deferred (BUG-347859 scenario preserved).

Verification Suggestion

Verify that the windowed launcher shows all apps immediately on startup with no progressive scrolling effect. Confirm that theme icons display correctly after theme initialization, and that apps with missing absolute-path icons are still deferred as before.


根因分析

commit 521429e("fix(appmgr): defer apps until theme icon resolves")扩展了 waitForIcon(),使主题图标名在 QIcon::fromTheme() 中暂时无法解析的应用也被延迟显示。启动器启动时图标主题尚未完全初始化,大量应用被放入待处理队列,每 3 秒才逐步释放(最长 120 秒超时),导致窗口模式下应用加载缓慢和渐进式滚动效果。

关键证据:appmgr.cpp:230-231 — QIcon::fromTheme(iconName).isNull() 主题图标名检查由 521429e 新增;appsmodel.cpp:48-56 — DFileWatcherManager 已监听 icon-theme.cache 变化并触发 updateIconData() 刷新图标,延迟逻辑并非必要。

修复方案

回退 commit 521429e 引入的主题图标延迟逻辑。waitForIcon() 恢复为仅延迟绝对路径图标文件不存在的应用(bug-347859 原逻辑)。checkPendingAppItems() 仅检查 QFileInfo::exists(),不再调用 IconUtils::tryUpdateIconCache()。超时从 40 次(120s)恢复为 20 次(60s)。移除仅被回退代码使用的 #include "iconutils.h" 和 #include <QIcon>。主题图标延迟可用由现有的 DFileWatcherManager + updateIconData() 机制处理。

改动安全评估

代码安全评估

  • 风险等级: 低风险
  • 被回退的代码由 commit 521429e(2026-08-11)为 BUG-371833 引入;本次改动为对称回退到 521429e 之前已验证的行为。bug-347859 原修复(绝对路径图标延迟)保持不变。
  • BUG-371833(主题图标为 null)仍由现有的 DFileWatcherManager + updateIconData() 机制覆盖,该机制在 521429e 之前已存在。调用方 AppsModel::shouldDelaySourceIndex() 逻辑不变,仅延迟条件缩小。

业务影响范围

受影响模块:启动器窗口模式应用列表显示。修复后启动器启动时所有应用一次性完整显示,不再渐进式加载。主题图标延迟可用仍通过图标缓存监听机制刷新。绝对路径图标暂不存在的应用仍被延迟显示(BUG-347859 场景保留)。

验证建议

验证窗口模式启动器启动后应用列表一次性完整显示,无渐进式滚动效果。确认主题初始化后图标正常显示,绝对路径图标缺失的应用仍正常延迟显示。

Summary by Sourcery

Restore responsive launcher startup by reverting unnecessary theme-icon deferral while preserving delayed handling for missing absolute-path icons.

Bug Fixes:

  • Restore immediate launcher app loading by stopping unresolved theme-name icons from being deferred during startup.
  • Continue deferring applications whose missing absolute-path icons are not yet available.

Enhancements:

  • Rely on the existing icon-theme cache watcher to refresh theme icons after initialization and reduce the pending-icon timeout to 60 seconds.

Chores:

  • Remove obsolete icon resolution dependencies and refresh logic from app management.

Revert the theme-icon deferral introduced in commit 521429e
("fix(appmgr): defer apps until theme icon resolves"). That change
extended waitForIcon() to also defer apps whose theme-name icon
QIcon::fromTheme() cannot resolve at startup, causing a large number
of apps to be queued and released only every 3s (up to 120s timeout)
— visible as slow/progressive app loading in windowed launcher mode.

Restore the original behaviour: only defer apps with absolute-path
icons whose file does not exist yet (bug-347859). Theme icons that
become available after startup are handled by the existing
DFileWatcherManager + updateIconData() mechanism in AppsModel.

Log: Revert theme icon defer logic to fix slow progressive app loading in windowed launcher.
PMS: BUG-372641
Influence: Windowed launcher now shows all apps immediately instead of progressive loading.

fix(appmgr): 回退主题图标延迟逻辑以修复应用加载缓慢

回退 commit 521429e("fix(appmgr): defer apps until theme icon
resolves")引入的主题图标延迟逻辑。该改动扩展了 waitForIcon(),
使主题图标名在 QIcon::fromTheme() 中暂时无法解析的应用也被延迟,
导致启动器启动时大量应用被放入待处理队列,每 3 秒才逐步释放
(最长 120 秒超时)——在窗口模式下表现为应用加载缓慢和渐进式滚动效果。

恢复原有行为:仅延迟绝对路径图标文件尚不存在的应用(bug-347859)。
主题图标延迟可用的问题由 AppsModel 中现有的
DFileWatcherManager + updateIconData() 机制处理。

Log: 回退主题图标延迟逻辑,修复窗口模式启动器应用渐进式加载缓慢问题。
PMS: BUG-372641
Influence: 窗口模式启动器现在一次性显示所有应用,不再渐进式加载。

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @mhduiy, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 5 hours and 24 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@deepin-ci-robot

Copy link
Copy Markdown

[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.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sourcery-ai

sourcery-ai Bot commented Sep 14, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Reverts theme-icon startup deferral so launcher apps are displayed immediately, while retaining deferral for missing absolute-path icons and the existing watcher-based theme icon refresh mechanism.

Sequence diagram for launcher icon loading after startup

sequenceDiagram
    participant AppsModel
    participant AppMgr
    participant DFileWatcherManager
    participant IconData

    AppsModel->>AppMgr: waitForIcon(desktopId, iconName)
    alt Theme-name icon or available icon
        AppMgr-->>AppsModel: false
    else Missing absolute-path icon
        AppMgr-->>AppsModel: defer app
        loop Every 3 seconds
            AppMgr->>AppMgr: checkPendingAppItems()
            AppMgr->>AppMgr: QFileInfo::exists(iconName)
        end
    end
    DFileWatcherManager->>IconData: updateIconData()
    Note over DFileWatcherManager,IconData: Refreshes theme icons when icon-theme.cache changes
Loading

File-Level Changes

Change Details Files
Restrict icon-based app deferral to missing absolute-path icon files, restoring immediate handling for theme-name icons.
  • Remove QIcon theme-resolution checks from the deferral and pending-item paths.
  • Preserve cancellation and deferral behavior for absolute-path icons based on file existence.
  • Remove now-unused icon utility and QIcon dependencies.
src/ddeintegration/appmgr.cpp
Restore the shorter pending-icon timeout while relying on the existing icon-theme watcher for later theme icon refreshes.
  • Stop refreshing the icon cache from the pending-item polling loop.
  • Reduce the timeout from 40 checks (120 seconds) to 20 checks (60 seconds).
  • Allow pending entries to be released based on file existence checks.
src/ddeintegration/appmgr.cpp

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 100 分,大于 70 分通过阈值,代码质量符合要求。本次变更为回退主题图标延迟逻辑,修复窗口模式下应用加载缓慢问题,代码逻辑正确,无安全漏洞。

📝 提交信息

项目 内容
PR 标题 fix(appmgr): revert theme icon defer to fix slow app loading
修改文件 src/ddeintegration/appmgr.cpp
提交目的 回退 commit 521429e 引入的主题图标延迟逻辑,修复窗口模式下应用渐进式加载缓慢问题

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅通过

具体分析:

  • waitForIcon() 函数(appmgr.cpp:225):新条件 !QFileInfo(iconName).isAbsolute() || QFileInfo::exists(iconName) 逻辑正确,仅当图标为绝对路径且文件不存在时才延迟显示
  • checkPendingAppItems() 函数(appmgr.cpp:268):简化为仅检查 QFileInfo::exists(it.value()),与新的延迟逻辑一致
  • 边界条件处理完善:空字符串图标名(!QFileInfo("").isAbsolute() 为 true,不延迟)、主题图标名(非绝对路径,不延迟)、绝对路径存在/不存在均正确处理
  • 移除 #include "iconutils.h" 和 #include <QIcon> 头文件,因为相关代码已被移除,无编译错误
  • 超时从 40 次(120s)减少为 20 次(60s),逻辑合理

潜在问题:
1.无 - 语法正确,逻辑清晰,边界处理完善

建议: 代码语法正确,逻辑清晰,无需修改


2. 代码质量 ✅

评价: 优秀 ✅通过

具体分析:

  • 移除了不再使用的 #include "iconutils.h" 和 #include <QIcon> 头文件,避免了不必要的依赖
  • 移除了不再适用的注释(关于主题图标延迟的注释),保留了 bug-347859 的注释引用
  • 简化了 waitForIcon() 和 checkPendingAppItems() 的复杂逻辑,减少了两个函数之间的重复代码
  • 原代码中 waitForIcon() 和 checkPendingAppItems() 存在重复的图标解析逻辑(QFileInfo::isAbsolute() + QIcon::fromTheme() 判断),简化后消除了重复
  • 代码自解释性提高,简化后的条件判断更直观
  • 无残留调试代码

潜在问题:
1.无 - 代码结构清晰,注释完整

建议: 代码结构清晰,移除了不再使用的头文件和复杂逻辑,良好实践


3. 代码性能 ✅

评价: 优秀 ✅通过

具体分析:

  • 移除 QIcon::fromTheme(iconName).isNull() 检查:QIcon::fromTheme() 需要在图标主题中查找,是一个相对昂贵的操作,移除后减少了每次定时器回调(3秒间隔)的计算开销
  • 移除 IconUtils::tryUpdateIconCache() 调用:减少了每次定时器回调中不必要的图标缓存更新操作
  • 超时从 40 次(120s)减少为 20 次(60s):由于延迟的项目数量减少(仅绝对路径图标缺失的应用),缩短超时时间合理
  • QFileInfo::exists() 比 QIcon::fromTheme().isNull() 更轻量,仅涉及文件系统检查
  • 整体减少了每 3 秒定时器回调中的计算量,对启动器启动性能有正面影响

潜在问题:
1.无 - 性能良好,资源使用合理

建议: 移除了QIcon::fromTheme()和IconUtils::tryUpdateIconCache()调用,减少了不必要的计算开销,性能表现良好


4. 代码安全 🔒

评价: 优秀 ✅通过

存在0个安全漏洞

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个

安全漏洞详情:
✅ 未发现安全漏洞

具体分析:

  • 本次变更仅涉及图标显示延迟逻辑的简化,不涉及用户输入处理
  • 不涉及敏感信息、命令执行、文件路径遍历等安全相关操作
  • QFileInfo::exists() 和 QFileInfo::isAbsolute() 均为只读文件系统查询操作,无安全风险
  • 代码变更不影响权限控制、认证授权等安全机制
  • 移除的 QIcon::fromTheme() 和 IconUtils::tryUpdateIconCache() 均为安全操作,移除不影响安全性

建议: 无安全风险,代码变更仅涉及图标显示逻辑,不涉及用户输入处理或敏感信息


📋 审查结论

本次 PR 回退了 commit 521429e 引入的主题图标延迟逻辑,目的是修复窗口模式下应用渐进式加载缓慢的问题。代码变更与 commit 目的完全一致:

  1. waitForIcon() 恢复为仅延迟绝对路径图标文件不存在的应用(bug-347859 原逻辑)
  2. checkPendingAppItems() 简化为仅检查文件是否存在,不再调用图标缓存更新
  3. 移除了不再需要的头文件引用
  4. 超时时间从 120s 恢复为 60s

主题图标延迟可用的问题(bug-371833)由现有的 DFileWatcherManager + updateIconData() 机制覆盖,无需额外延迟逻辑。代码逻辑正确,无安全漏洞,性能提升,代码质量良好。


本报告由 AI 代码审查工具自动生成

@mhduiy

mhduiy commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

该问题已修复,关闭此PR

@mhduiy mhduiy closed this Sep 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants