Opened 6 years ago
Closed 4 years ago
#5055 closed defect (fixed)
Lagging while pressing the Shift hotkey
Reported by: | elexis | Owned by: | bb |
---|---|---|---|
Priority: | Release Blocker | Milestone: | Alpha 24 |
Component: | Core engine | Keywords: | |
Cc: | Krinkle | Patch: | Phab:D1398 |
Description
As reported on the forums by wowgetoffyourcellphone and confirmed by LionKanzen in https://wildfiregames.com/forum/index.php?/topic/24062-lagging-when-using-shift-modifier-key/ on windows, but apparently not on linux the game is lagging while pressing shift.
This is most likely due to the key event frequency being different on windows, thus the selection panels and barter dialog being updated way more often than on linux.
Setting a max update frequency in JS would be sufficient to remove the FPS drainage.
Not sure if it is a good idea or worth the effort to set a fixed event frequency in the C++ part for all input events.
Attachments (1)
Change History (12)
comment:1 by , 6 years ago
comment:3 by , 6 years ago
Last couple of days I have been looking into this with the idea to split the "Press" action into two parts: one which acts like the current hotkey (1 break, spam) and one which only fires once. The gui page could then simply specify which of the two it wants/needs and f.e. the massbarter and batchtrain could use the "once" option.
However I ran into some SDL issues: the exists a repeat flag which should specify if it is the first or nonfirst message, but "should". On my machine the flag is empty on all calls (for both Xorg and wayland) on for Imarok it contains 4 on all calls (no idea what "4" means here), thus that flag seems bugged on SDL side. Ofc it wouldn't be hard to just keep trac of the pressed hotkeys and so filter out the repeated keys, but that sounds hackish.
comment:4 by , 6 years ago
Looks like SDL_EnableKeyRepeat doesn't exist anymore in SDL2: https://www.libsdl.org/release/SDL-1.2.15/docs/html/sdlenablekeyrepeat.html
The repeat flag is documented here: https://wiki.libsdl.org/SDL_KeyboardEvent It would be much better to use one of the two functions to identify keyrepetitions.
Looking at the diff you have tested with Imarok https://pastebin.com/LG7ghpdA that is a HotkeyDown event and not a KeyDown event and you should only print that repeat flag if the event is actually a keydown event to exclude false positives. That number was 59 when I tried it the first time and I think that's just an uninitialized value that I'm surprised even compiles. (Also the code in your paste shouldnt trigger release events on repeated keydown events.)
To me it looks like the repeat flag should be read from the SDL_KEYDOWN event and copied to the SDL_HOTKEYDOWN event we construct in Hotkey.cpp
.
comment:5 by , 6 years ago
Patch: | → D1398 |
---|
comment:6 by , 6 years ago
Patch: | D1398 → Phab:D1398 |
---|
comment:8 by , 5 years ago
Component: | UI & Simulation → Core engine |
---|
comment:9 by , 5 years ago
Priority: | Should Have → Release Blocker |
---|
comment:10 by , 5 years ago
Cc: | added |
---|
I don't think, that we should make the frequency lower. Because then players with a fast pressing may notice, that keys aren't handled immediately. So I suggest to add a logic/flag about press/release: if a key is pressed/down, then send an event only once and don't send until it'll be released/up.