RobustToolbox icon indicating copy to clipboard operation
RobustToolbox copied to clipboard

Sending WM_INPUTLANGCHANGEREQUEST hangs the game

Open koteq opened this issue 1 year ago • 4 comments
trafficstars

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

koteq avatar Jan 21 '24 15:01 koteq

Can you send actual debugger stack traces or a minidump when this happens? I can't reproduce it locally and the code and blog posts you've linked are complete bogus.

PJB3005 avatar Jan 22 '24 11:01 PJB3005

@PJB3005, unfortunately, I'm not skilled at debugging and memory dumping. I've taken something that looks like a minidump with the help of the procdump tool, launching it as follows .\procdump.exe -w -h -n 3 SS14.Loader.exe, which produced three dumps when the game hung for more than 5 seconds. ~~https://drive.google.com/drive/folders/1XAvj_QbnFv51o3BQAIQzSHSzMK6YbP5h?usp=drive_link~~

While taking those dumps, I've noticed that I can't reproduce the bug while the game is in the windowed mode. I also noticed that the game continues to render normally, only my keyboard and mouse input hangs. I also noticed that if during the hang I stop pressing buttons, there is a decent chance the game unhang by itself. On the other side, if I'd continue mashing buttons and move the mouse during the hang, the mouse cursor would change to the spinner, then the whole window would get the pale-white overlay, and then Windows would kill the process. Surprisingly, I can't reproduce the bug while OBS is running, as if those things that OBS injects for proper recording are interfering with the bug somehow. I can still record it using a mobile phone to prove it's there.

koteq avatar Jan 22 '24 13:01 koteq

For reference that memory dump is what I wanted, though I didn't end up gleaning too much from it.

Considering the game unstucks I'm piling this on a list of "cursed GLFW bugs" and saying we probably can't fix this.

PJB3005 avatar Jan 22 '24 14:01 PJB3005

I see, thanks for your time, anyway.

koteq avatar Jan 22 '24 14:01 koteq

Closing since GLFW is no longer default.

PJB3005 avatar Sep 26 '25 22:09 PJB3005