Skip to content

Remove Timer from WindowsKeyboardSwitchingAdapter and add IME diag#1495

Open
jasonleenaylor wants to merge 1 commit intomasterfrom
bugfix/imeKeyboardGlitches
Open

Remove Timer from WindowsKeyboardSwitchingAdapter and add IME diag#1495
jasonleenaylor wants to merge 1 commit intomasterfrom
bugfix/imeKeyboardGlitches

Conversation

@jasonleenaylor
Copy link
Copy Markdown
Contributor

@jasonleenaylor jasonleenaylor commented Mar 27, 2026

Replace the Timer-based deferred IME conversion status restore with synchronous restore. The Timer caused jittery, unreliable IME switching for Chinese Pinyin and other TSF-based IMEs. The synchronous approach ensures ImmSetConversionStatus is applied before any subsequent SaveImeConversionStatus can capture stale values.

Add Trace.WriteLine diagnostic logging throughout keyboard switching, IME save/restore, and post-switch state verification to aid debugging of intermittent IME composition issues.


Open with Devin

This change is Reviewable

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 3 potential issues.

View 2 additional findings in Devin Review.

Open in Devin Review

Comment on lines +67 to +68
RestoreImeConversionStatus(keyboard);
TraceImeState("PostSwitch", focusAfter, keyboard);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚩 Removal of Timer-based IME retry may regress intermittent IME activation issues

The old code had a Timer (500ms interval) that would call RestoreImeConversionStatus a second time after keyboard switching, with the comment "Restore it even though sometimes windows will ignore us" and "Start the timer for restoring IME status for when windows ignores us." This was a deliberate workaround for an intermittent Windows behavior where the OS would silently reset IME conversion status shortly after it was set. The new code calls RestoreImeConversionStatus only once (line 67) and relies on the added diagnostic tracing to investigate the root cause instead. This is a reasonable approach for diagnosis, but the behavioral change means IME users (particularly Chinese/Japanese/Korean input) may see the intermittent mode-reset issue return until a more robust fix is implemented.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The Timer and the restore it attempted was very clearly the source of an intermittent error with Chinese Pinyin IME keyboards that rendered them unusable for a subset of users. The reason for it was actually removed quite a while back and testing so far indicates that all switching is working better without the timer now.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 27, 2026

Palaso Tests

     4 files  ±0       4 suites  ±0   10m 44s ⏱️ +33s
 5 095 tests ±0   4 861 ✅  - 1  233 💤 ±0  1 ❌ +1 
16 597 runs  ±0  15 876 ✅  - 2  720 💤 +1  1 ❌ +1 

For more details on these failures, see this check.

Results for commit ea7c9a2. ± Comparison against base commit ce83cef.

♻️ This comment has been updated with latest results.

…tics

Replace the Timer-based deferred IME conversion status restore with
synchronous restore. The Timer caused jittery, unreliable IME switching
for Chinese Pinyin and other TSF-based IMEs. The synchronous approach
ensures ImmSetConversionStatus is applied before any subsequent
SaveImeConversionStatus can capture stale values.

Add Trace.WriteLine diagnostic logging throughout keyboard switching,
IME save/restore, and post-switch state verification to aid debugging
of intermittent IME composition issues.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jasonleenaylor jasonleenaylor force-pushed the bugfix/imeKeyboardGlitches branch from c509789 to ea7c9a2 Compare April 7, 2026 20:52
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.

1 participant