Repository navigation
Description
Describe the bug
On Windows, switching between two native windows containing Wry webviews can cause Chinese IME composition/preedit UI to lose its caret positioning. Instead of remaining inline in the active textarea or next to its caret, the composition UI can appear in a separate floating window at the top-left corner of the screen (0, 0).
Direct English input still works. The problem is not consistently tied to one window: one window may work normally while the other has broken IME positioning, and the affected window can change during repeated switching. It often occurs when returning to a previously focused window.
An important comparison in the Tauri application is that returning to an application window from an external application normally works, while switching between windows of the same application triggers the problem. This describes the observed reproduction pattern, rather than a claim that all external-application transitions are unaffected. The external-application control case has not yet been separately verified in the attached standalone reduction.
I observed this with both Microsoft Pinyin and WeChat Input Method (Chinese Pinyin).
Steps To Reproduce
- Extract the attached
wry-ime-window-switch-repro.zip. It contains a standalone Rust project using Wry and Tao directly, with no Tauri dependency. - Run:
cargo run --locked
- Enable a Chinese Pinyin IME.
- Click the textarea in window A, type and commit some Chinese text.
- Switch to window B, click its textarea, and type Chinese text.
- Return to A and type Chinese again. Repeat A → B → A → B several times.
After a window regains focus, the IME composition UI may appear at the screen origin instead of at the caret. The other window may still work, and the affected window can change on subsequent switches.
The reproduction setup uses one Tao event loop, two native windows, a shared Wry WebContext, and a plain textarea in each webview. There are no custom native window hooks, programmatic focus/blur calls, editor frameworks, or IME recovery code in the attached reduction. The page script only observes focus/composition events and displays a counter.
Expected behavior
Each time either window receives focus, Chinese composition should remain inline in the focused textarea, and the candidate/composition UI should be positioned at the caret.
Screenshots
In one captured failure, a detached IME composition window appeared at screen coordinates (0, 0), while the test page still displayed “Waiting for input”.
Platform and Versions (please complete the following information):
OS: Windows 11 Pro, build 26200 (10.0.26200), x64
Rustc: rustc 1.96.0 (ac68faa20 2026-05-25)
Versions used in the standalone test where the symptom was observed:
- Wry: 0.57.0
- Tao: 0.37.1
- WebView2 Runtime: 142.0.3595.69
- IMEs: Microsoft Pinyin and WeChat Input Method (Chinese Pinyin)
Additional context
- The symptom was initially observed in a Tauri application (Tauri 2.12.1), then also in a separate direct Tao/Wry test with two plain textareas.
- The attached source is a reduction of that standalone setup and has been build-checked. This newly packaged reduction has not yet been manually retested.
- The Tauri application has since been upgraded to Tauri 2.12.5 / tauri-runtime-wry 2.12.3 / Wry 0.57.1 / Tao 0.37.2, and manual testing after the upgrade still reproduces the problem. The upgraded versions were verified in the running application. This newer-version result is from the Tauri application; the standalone test result above remains scoped to Wry 0.57.0 / Tao 0.37.1.
- WebView2 Runtime remains 142.0.3595.69; a newer Runtime has not yet been tested.
- Automated interactions appeared to introduce extra focus transitions and could mask the failure. Manual switching is the relevant reproduction path.
- Other background applications were not fully excluded. This report does not establish whether the root cause is in Wry's hosting/focus handling, Tao, WebView2, or the IME.
wry-ime-window-switch-repro.zip
Potentially related reports:
- [bug] IME window position appears out of input/textarea (cannot inline-input) on Tauri v2 apps in Linux tauri#11412 — composition UI outside the input, but on Linux/WebKitGTK.
- [bug] [Windows] WebView2 IME/TSF freezes on first focus of inputs with existing text (CJK input methods blocked) tauri#15436 — Windows IME composition problems after focusing an input with existing text.
- [Problem/Bug]: IME composition window jumps to the top-left of the screen after the host window is resized MicrosoftEdge/WebView2Feedback#5675 — composition UI at the screen origin after host-window resizing.
The triggers and platforms differ, so I am linking these for context rather than assuming they are duplicates.
Is there a known issue or recommended handling for restoring the IME text-input context/caret positioning when switching between multiple native windows hosting Wry webviews?
Activity
TakahiroNago commentedon Nov 8, 2026
I was able to reproduce this issue using the standalone Wry/Tao reproduction project.
My observations:
I have not identified the root cause yet. I plan to investigate the Windows focus handling and IME-related behavior in Wry and Tao, and will share any findings or a potential fix.
I hope these additional reproduction results are helpful.
TakahiroNago commentedon Nov 8, 2026
I ran a set of controlled experiments with the standalone Wry/Tao reproduction.
Environment
Method
An automated PowerShell harness alternately clicks the textarea in window A and B,
turns the IME on (via WM_IME_CONTROL on the default IME window), types one key, and records
(a) whether the page received
compositionstartand (b) which IME UI windows were shown(SetWinEventHook). 20 trials per run. Manual verification is still pending.
Failure signature: the browser process shows an
MSCTFIME Composition/CiceroUIWndFramewindow at the top-left of the screen and the page never gets
compositionstart(same state as the screenshot in the original report).
Results (failures / 20)
MoveFocusonWM_SETFOCUSMoveFocusafterDefSubclassProc, only ifGetFocus()is still the parent (no deferral)MoveFocusdeferred viaPostMessageGetFocus()is still the parent HWNDIn the unmodified configuration one of the two webviews fails on every visit while the other
keeps working; which one is affected varies between runs.
Interpretation
The failures need two things at once: both webviews in t
MoveFocus(PROGRAMMATIC)being called synchronously inside the host window'sWM_SETFOCUS(src/webview2/mod.rs, parent subclass). Logging inside wry shows that focus has already moved
into the WebView2 HWND by the time
MoveFocusreturns, i.e. before Windows has finished theactivation sequence. Deferring the call past the activation avoids the problem.
Microsoft's WinForms control also calls
MoveFocusonGotFocusand reproduces the samefailure rate, so the underlying problem is most likely ily avoid
triggering it. I intend to report it to WebView2Feedback as well.
Proposed direction
On
WM_SETFOCUS, post a registered message instead of callingMoveFocusdirectly; in thehandler call
MoveFocus(PROGRAMMATIC)only if `GetFocus(so aclick that already focused the webview is left alone). This keeps the Alt+Tab / programmatic
re-activation behaviour from #676.
Before opening a PR I'd appreciate feedback on whether ttended
Windows focus handling, and whether deferring
MoveFocusraises any concerns (e.g. with#1910 or multi-webview windows). I can share the harnessatch.
TakahiroNago commentedon Nov 8, 2026
Opened #1924 with the deferred/conditional
MoveFocuschange described above.docs(windows): explain the title-bar focus timing of the deferred Mov…
fix(window): 修复输入法候选框在窗口重新激活后飘到屏幕左上角