RobustToolbox
RobustToolbox copied to clipboard
Sending WM_INPUTLANGCHANGEREQUEST hangs the game
Description
I'm using an input language switcher that sends the WM_INPUTLANGCHANGEREQUEST message. Time to time, the message hangs the game client, causing it to terminate shortly. That's probably a niche bug, but I still wanted to report it. Mayhaps it has some simple solution I'm unaware of.
Reproduction
- Have a Windows OS with IME and multiple languages and keyboard layouts installed. For me, it's the Windows 11 version 22H2 with English and Russian languages.
- Send the WM_INPUTLANGCHANGEREQUEST message to the game's window a couple of times until it hangs. I'm using https://github.com/valodzka/lswitch/blob/master/lswitch/lswitch.c#L21 for that, it allows me to use CapsLock as an input language switch button. There are other keyboard layout switchers exist that send the message.
Additional context
Apparently, it's a known issue related to threads deadlocking, in a great detail explained in Marc Durdin's Blog:
Probably, those are culprits: https://github.com/space-wizards/RobustToolbox/blob/bcaa97a79be1afb9823832a790dbf9b5512965cd/Robust.Shared/Timing/PrecisionSleep.cs#L87 https://github.com/space-wizards/RobustToolbox/blob/bcaa97a79be1afb9823832a790dbf9b5512965cd/Robust.Shared/Utility/WaitHandleHelpers.cs#L12