fix(desktop): 避免 Provider I/O 阻塞 Windows 界面线程 - #13
Open
TorbenXiong wants to merge 1 commit into
Open
Conversation
将 Provider 枚举、文件读取和 JSON 解析移至 blocking worker,并通过异步 Tauri command 调用。 系统托盘先创建轻量菜单,再在后台构建完整菜单。托盘刷新采用 single-flight 和请求合并机制,避免并行构建导致旧菜单覆盖最新状态。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
桌面端启动时会读取本地 Provider 配置。变更前,Provider 目录枚举、文件读取和 JSON 解析均由同步 Tauri command 执行,系统托盘初始化也会同步执行相同操作。
在 Provider 文件较多、文件异常膨胀、磁盘响应较慢或文件受到安全软件扫描时,这些同步 I/O 可能阻塞 Windows 界面线程,导致窗口首帧白屏或短暂无响应。
一般只有少量 Provider 时,修复前后的性能差异通常不明显。本次修改主要用于消除潜在的界面线程阻塞,提高异常和高负载场景下的稳定性。
修改内容
list_providers改为异步 Tauri command。复现方式
使用独立测试配置生成 3,000 个合法 Provider 文件,每个文件约 256 KiB,总大小约 788 MB。
文件只包含合成测试数据,不包含真实账号或凭据。该负载用于稳定放大同步 I/O 阻塞,便于捕获变更前后的首帧差异。
测试结果
变更前
变更后
截图
变更前:窗口首帧白屏
变更后:窗口首帧正常渲染
验证
cargo fmt --checkcargo clippy --all-targets -- -D warnings影响范围
本次修改针对 Provider 同步 I/O 导致的界面线程阻塞,不代表已经解决所有可能由 WebView 或窗口生命周期引起的本地白屏问题。