Skip to content

Fix: UI performance when downloading - #53

Merged
Lakr233 merged 2 commits into
Lakr233:mainfrom
eric1932:fix/download-progress-ui-performance
Feb 28, 2026
Merged

Fix: UI performance when downloading#53
Lakr233 merged 2 commits into
Lakr233:mainfrom
eric1932:fix/download-progress-ui-performance

Conversation

@eric1932

Copy link
Copy Markdown
Contributor

下载 IPA 过程中滑动下载页面会出现明显的卡顿和设备发热,原因是整个页面 UI 一直被下载进度更新导致重绘。

做了以下修改

  • 提取 PackageManifestRow 避免进度更新导致整个页面被重绘
  • 限制 200ms 更新一次进度
  • hash(into:) 函数中移除了 state,避免可变状态影响 hash 稳定性

Move per-manifest row content from DownloadView's ForEach closure into
a dedicated PackageManifestRow view. This isolates @observable property
reads (state.percent, hint) to each row's own observation scope, so
progress changes on one manifest only re-render that specific row
instead of the entire download list.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

@bo2themax bo2themax left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

其他页面也在用Downloads,移除state在我看来影响范围不确定。
如果只是这个页面卡顿的话建议移除 @State 试下

- Throttle .progress{} callback to fire at most once per 200ms (always
  allow fraction >= 1.0 through immediately). Reduces UI updates from
  dozens/sec to ~5/sec per download.
- Batch two separate struct field mutations into a single copy-modify-
  assign, halving @observable withMutation notifications per update.
- Remove saveManifests() from progress/speed callbacks. Progress
  percentage is transient state; terminal state changes (complete,
  pause, error) already persist via their own saveManifests() calls.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@eric1932
eric1932 force-pushed the fix/download-progress-ui-performance branch from b6b08ba to 810061b Compare February 28, 2026 15:04
@eric1932

Copy link
Copy Markdown
Contributor Author

hash 函数还原了

CleanShot 2026-03-01 at 00 19 00@2x

尝试了移除@State,还是会卡

还是需要隔离组件 & 控制刷新频次(现有的两个 commit)

@eric1932
eric1932 requested a review from bo2themax February 28, 2026 16:22
@Lakr233
Lakr233 merged commit d55eb17 into Lakr233:main Feb 28, 2026
2 checks passed
@eric1932
eric1932 deleted the fix/download-progress-ui-performance branch March 2, 2026 17:57
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.

3 participants