Skip to content

PIMETextService: don't block the host UI thread while the launcher is unreachable (#942) - #972

Open
ilwu wants to merge 1 commit into
EasyIME:masterfrom
ilwu:fix-942-pipe-connect-freeze
Open

ilwu wants to merge 1 commit into
EasyIME:masterfrom
ilwu:fix-942-pipe-connect-freeze

Conversation

@ilwu

@ilwu ilwu commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #942 with option 3 from the issue (short timeout, immediate exit when the pipe does not exist), plus a cool-down so a disconnected client does not probe the pipe on every key stroke.

  • WaitNamedPipe() timeout per attempt: 3000 ms → 200 ms (kPipeWaitTimeoutMs), still up to 3 attempts.
  • connectPipe() gets an optional bool* retryable out-parameter: true only for ERROR_SEM_TIMEOUT (pipe exists, all instances busy). Any other failure — typically ERROR_FILE_NOT_FOUND when PIMELauncher is not running — ends the retry loop at once.
  • After a failed connection, including a pipe that connected but whose init() failed, waitForRpcConnection() returns false immediately for the next second (nextConnectAttemptTick_, GetTickCount64()), so the keys typed meanwhile go to the application.

waitForRpcConnection() runs on the host's UI thread for every key while disconnected. With a launcher whose pipe exists but does not answer, 3 × 3000 ms froze the host for up to 9 s per key; a backend that accepts the pipe but fails init() cost a full RPC timeout (kServerStartupTimeoutMs = 15 s since #931) per key. Worst case is now 600 ms, followed by a one-second window in which the host is responsive.

I could not compile this locally (no MSVC here), so I am relying on the CI build; the change is confined to PIMEClient.cpp/.h and uses only windows.h APIs that were already available (GetTickCount64, ERROR_SEM_TIMEOUT). Happy to adjust the constants if you prefer other values.

Generated with assistance from Claude Code (Claude Fable 5.1).

🤖 Generated with Claude Code

… unreachable (EasyIME#942)

* WaitNamedPipe() timeout per attempt goes from 3000 ms to 200 ms.
* Stop retrying as soon as the failure is not ERROR_SEM_TIMEOUT, e.g.
  ERROR_FILE_NOT_FOUND when PIMELauncher is not running; connectPipe()
  reports this through a new optional `retryable` out-parameter.
* After a failed connection (pipe unavailable, or init() failing on the
  new pipe) skip reconnection attempts for one second so that the keys
  typed meanwhile go straight to the application instead of each one
  probing the pipe again.

waitForRpcConnection() runs on the UI thread of the host application
for every key stroke while the client is disconnected. With three
3-second waits in a row, a launcher whose pipe exists but does not
answer froze Notepad, Word or the browser for up to nine seconds per
key, and a backend that accepts the pipe but fails init() cost a full
RPC timeout per key. The worst case is now 600 ms, followed by a
one-second pause in which the application is responsive.

Generated with assistance from Claude Code (Claude Fable 5.1).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
asdf80730 added a commit to asdf80730/PIME that referenced this pull request Oct 20, 2026
EasyIME#961 is fixed via EasyIME#964; EasyIME#942 now has EasyIME#972; EasyIME#936/EasyIME#937 gained EasyIME#971, which
patches the vendored nime. ARM64 installs register an ARM64X forwarder,
so the architecture summary and installer card say so. Add the new EasyIME#966
issue and a short note on what moved upstream since 24e4dff.

This branch has not been deployed

No deployments
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.

PIMETextService: UI thread freeze on named pipe connection when launcher is unresponsive

1 participant