fix(WeaselServer): avoid tray refresh blocking IPC pipe - #1912
Merged
Conversation
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)
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.
概要
fixed: #1909。
服务端在 pipe worker 线程中刷新托盘图标时,
Shell_NotifyIcon可能在持有g_api_mutex的情况下阻塞;如果 Explorer/任务栏同时等待 IPC 管道,就可能导致服务端 IPC 管道卡住。本次修改:
PostMessage失败,避免内存泄漏和刷新永久丢失。SetOption后立即刷新 UI,使ascii_mode切换及时反映到托盘图标。测试