← All issues

macOS IM: per-keydown command queue for Zhuyin TCIM

2b95292

Source/WebKit/UIProcess/mac/WebViewImpl.h

- std::optional<Vector<WebCore::KeypressCommand>> m_collectedKeypressCommands;
- Vector<Function<void()>> m_interpretKeyEventHoldingTank;
+ Deque<Vector<WebCore::KeypressCommand>> m_collectedKeypressCommands;
+ Deque<Function<void()>> m_interpretKeyEventHoldingTank;

WebKit on macOS routes keyboard events through NSTextInputClient's handleEventByInputMethod:, which dispatches asynchronously to system input methods over XPC. A prior fix (297270@main) introduced m_interpretKeyEventHoldingTank to enforce DOM event ordering: keydown must reach the web process before any compositionstart/update events the IM emits. All keyboard events were serialized through that tank — but the Traditional Chinese Zhuyin IM uses its XPC queue depth as a liveness signal, and the empty queue stalled its main thread. The fix makes keydowns bypass the tank, feeding the IM continuously, while keyups remain serialized through a Deque so the front slot always corresponds to the keydown the IM is currently processing.

This replaces a flat holding tank with a per-keydown Deque that allows multiple keydowns to be simultaneously in-flight to the IM — a meaningful concurrency-model change to a security-sensitive input pipeline.

🔒

New concurrent in-flight keydown model introduces ordering invariants and async re-entrancy paths worth auditing for command misrouting and memory safety.

Subscribe to read more