libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
10.23k stars 1.87k forks source link

On intel macOS after taking an area screenshot / video recording all keyboard inputs are ignored #7507

Closed PunkPun closed 1 year ago

PunkPun commented 1 year ago

2.26.0 - 2.26.5: bug present 2.24.0 - 2.24.2: crash on launch, couldn't test 2.0.18 and 2.0.22: bug not present

All versions tested on Monterey 2.0.18 and 2.26.1 also tested on Ventura

icculus commented 1 year ago

This is working here, on an M1 Mac running Sonoma (14.1.1), using testwm2. Was it literally an Intel Mac required to trigger this?

I'm also wondering if OpenRA is ignoring input after a screenshot, maybe because it thinks the game lost keyboard focus? I'll have to test the actual game, if I can do so relatively easily.

icculus commented 1 year ago

OpenRA "fixed" it by downgrading to SDL 2.0.22. 😬

icculus commented 1 year ago

Ok, new notes:

I tried the latest OpenRA download, launched Red Alert, let it download the free game data, started a single player skirmish.

Recorded a video from a section of the window with Command-Shift-5, could move the map with arrow keys during and after the recording. Pressed escape, then clicked Back until I could quit the game.

Replaced the game's SDL2.dylib with one built from the latest in revision control, and tried again.

Arrow keys still worked, but Escape did not when I tried to bring up the menu to quit out. You don't even have to record a video, just pop up Apple's UI with Command-Shift-5 and hit escape to leave it.

Changing to a different window and returning fixed this issue.

Escape key events are definitely still being sent in this scenario in the SDL2 test app.

The app also deadlocks when quitting with the newer SDL2 and has to be force-quit, even if you just launch the app and leave immediately without screenshots or even starting a game, but that's a different bug somewhere.

slouken commented 1 year ago

Good catch, it sounds like we have some regressions to fix for 2.30 :)

icculus commented 1 year ago

ONE MORE THING, sorry.

testwm2 is reporting LSHIFT and LGUI mods are stuck down when Apple's screenshot UI comes up and is dismissed, and sure enough, if I press and release each of those keys, the mod flags unstick, and OpenRA works as expected again. It apparently cares if those mod flags are set and ignores various keys if they are.

So this is probably in fact an SDL bug. Let me see if I can figure out what changed since 2.0.22 to cause those mod flags to stick in this situation.

icculus commented 1 year ago

Bisecting says this is the culprit: https://github.com/libsdl-org/SDL/commit/7e1088167a7cf47ca920667743e84cacb82af481

icculus commented 1 year ago

So this change was because of #6405, and I'm wondering if we should just back it out.

EDIT: although I bet it fixed things like #8156, so maybe I'll actually debug this instead. :)

icculus commented 1 year ago

This is fixed in revision control now, but the latest SDL2 still makes OpenRA hang on exit. Trying to figure out how to debug it, since LLDB can't attach to it for some reason...? I'll report back.

PunkPun commented 1 year ago

Many thanks. We did also have these 2 bugs https://github.com/OpenRA/OpenRA/issues/20715 https://github.com/OpenRA/OpenRA/issues/20642 which were very likely fixed by the downgrade.

I haven't investigated them, but it might be important to check them out