Skip to content

fix(WeaselServer): avoid tray refresh blocking IPC pipe - #1912

Merged
fxliang merged 1 commit into
rime:masterfrom
fxliang:tray
Aug 18, 2026
Merged

fix(WeaselServer): avoid tray refresh blocking IPC pipe#1912
fxliang merged 1 commit into
rime:masterfrom
fxliang:tray

Conversation

@fxliang

@fxliang fxliang commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

概要

fixed: #1909

服务端在 pipe worker 线程中刷新托盘图标时,Shell_NotifyIcon 可能在持有 g_api_mutex 的情况下阻塞;如果 Explorer/任务栏同时等待 IPC 管道,就可能导致服务端 IPC 管道卡住。

本次修改:

  • 将托盘图标更新转移到 server 消息线程执行。
  • 合并待处理的刷新请求,只应用最新状态。
  • 处理 PostMessage 失败,避免内存泄漏和刷新永久丢失。
  • 退出时停止并等待托盘刷新完成。
  • SetOption 后立即刷新 UI,使 ascii_mode 切换及时反映到托盘图标。
  • 不修改客户端 IPC 流程。

测试

  • 已在 Windows 环境手工编译通过。

@lotem lotem left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

善哉

@fxliang
fxliang merged commit d73f629 into rime:master Aug 18, 2026
3 checks passed
Wujidadi added a commit to Wujidadi/weasel that referenced this pull request Aug 22, 2026
- 合入 rime/weasel master 至 d73f629,含 rime#1912 托盤刷新改於伺服器訊息執行緒執行,與本 fork 的客戶端有界逾時修補互補
- weasel.props.template 移除與上游重複的版本巨集定義
- build.bat 的 fork 版號後綴進位 -wujidadi.3
- FORK-CHANGELOG 新增 0.17.4-wujidadi.3 節
- appcast 與 testing-appcast 條目更新至 0.17.4-wujidadi.3
Wujidadi added a commit to Wujidadi/weasel that referenced this pull request Aug 22, 2026
rime#1912 把 `Shell_NotifyIcon` 從管線工作執行緒移到伺服器訊息執行緒,但訊息執行緒同時擁有候選視窗。
管線工作執行緒在 `FocusIn` → `_UpdateUI()` 仍會對候選視窗做跨執行緒的 ShowWindow/SetWindowPos,這些呼叫會同步送訊息給訊息執行緒;
而 `Shell_NotifyIcon` 內部以 `SMTO_BLOCK` 等待工作列,期間不處理送入的訊息。
當工作列 UI 執行緒本身正在等管線回應時,工作執行緒等待訊息執行緒、訊息執行緒等待工作列、工作列等待工作執行緒的環仍可能成立。

- WeaselTrayIcon 改由專用執行緒套用刷新:`RequestRefresh()` 只存快照並喚醒,`RefreshThreadProc()` 合併待處理請求後呼叫 `Refresh()`,`DisableRefresh()` 停止並 join。
- 移除 rime#1912 引入、現已無用的 `WM_WEASEL_SERVICE_NOTIFY`、`ServerImpl::OnServiceNotifyMessage` 與 `Server::SetTrayRefreshCallback`。
- 移除 `_RefreshTrayIcon()` 對 explorer.exe 延遲 100ms 另開執行緒的繞道:回呼已不再阻塞,對任何客戶端同步呼叫皆安全。

(cherry picked from commit cbc4f32)
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.

WeaselIPC 客戶端在宿主程式 UI 執行緒上無限等待伺服器,切換視窗時造成卡頓或視窗凍結 7~8 秒

2 participants