pqrs-org / Karabiner-Elements

Karabiner-Elements is a powerful utility for keyboard customization on macOS Sierra (10.12) or later.
https://pqrs.org/osx/karabiner/
The Unlicense
18.67k stars 836 forks source link

Random key repeating when under high load #545

Closed neilio closed 6 years ago

neilio commented 7 years ago

I'm still trying to narrow down if this is definitely Karabiner or something else, but I've noticed if my machine is under high CPU load that typed character often get "stuck" - pressing a key makes it repeat multiple times even though I'm not holding it down.

Has anyone else seen this?

zhenchaoli commented 7 years ago

Similar issue here. Not 100% sure if it's Karabiner either. But it's one more sample :)

jessejanderson commented 7 years ago

Same issue here, I've had it happen twice now (once with left arrow, once with volume-down -- both while machine was cranking, fans spinning, etc).

codyrobbins commented 7 years ago

Same thing here. It’s happening quite often for me on an older 2010 MacBook Air.

modkaffes commented 7 years ago

Same here and it's happening really often, even under light CPU usage.

When using Chrome and ctrl-tabbing to next tab, it seems that the ctrl-tab combination stays "pressed" for a while and it jumps five tabs ahead instead of one. I've also noticed when text editing, the space key gets "stuck" at times.

Only modification I've enabled is non_us_backslash to grave_accent_and_tilde.

Karabiner-Elements version: 0.90.79

tekezo commented 7 years ago

Karabiner-Elements leaves the key repeat handling to macOS since v0.90.69. So, if this issue is happen in the recent version, it's a macOS issue.

codyrobbins commented 7 years ago

@tekezo I can’t test definitively whether it is Karabiner, because my keyboard still stops working entirely when I quit Karabiner, but I think it may be Karabiner rather than macOS because I don’t remember it starting to occur after a macOS update.

tisba commented 7 years ago

This might be related to https://github.com/tekezo/Karabiner-Elements/issues/510, https://github.com/tekezo/Karabiner-Elements/issues/466 and several other issues.

chellberg commented 7 years ago

I'm experiencing this too, and I think it started after either the most recent or the second most recent Karabiner update. I don't think I've installed any macOS updates recently.

Mauin commented 7 years ago

I'm seeing the same. Using my 60% (GON NerD) standing on top of my MacBook keyboard. Using Karabiner to disable the internal MacBook keyboard. Under high load it seems like turning off the internal keyboard seems to cut out as some keypresses from the internal keyboard get registered and at some point I get the stuck key issue. Only restarting the MacBook solves the stuck key issue for me.

RobertARandolph commented 7 years ago

This happens to me frequently and turning off karabiner-elements makes the issue go away.

EleanorRagone commented 7 years ago

I'm having this issue and it is 100% due to karabiner-elements. I absolutely love being able to tweak keyboard to exactly what I want, but if it's going to put in a bunch of random letters at random times, I can't use it! Is there any work on a fix?

jessejanderson commented 7 years ago

It's pretty bad - consistently seeing this behavior several times a day.

Turning off karabiner-elements fixes the issue.

tadaszelvys commented 7 years ago

I have this issue too, mbp 2015, on heavier load it becomes a real problem as pressing a key will result in random amount of repeats.

EleanorRagone commented 7 years ago

So... any updates on this? @tekezo? Anything we can do to help out?

EleanorRagone commented 7 years ago

Any chance we can get an update on this of some kind? It's getting really, really frustrating to have all my programs quit because karabiner keeps repeating key commands like "cmd-q"

daniula commented 7 years ago

I have the same issue on new Macbook 13" Early 2015. I'm suspecting Karabiner and since I've disabled it, issue is gone.

Karabiner version: 0.90.86 macOS: 10.12.3

MartinNuc commented 7 years ago

Had this issue all time time since using Karabiner Elements. Began to use it very early when the only way to config was through editting config file.

Same as others. After I quit Karabiner issue is gone.

Currently Karabiner version: 0.90.86 macOS: 10.12.3

sprout42 commented 7 years ago

I've had this happen to me a few times now. Occasionally I get a lag when typing, and worst sometimes delete seems to get stuck and keeps deleting things until I hit the control key (for some reason). I been unable to identify any pattern behind this happening.

Does not happen when Karabiner Elements is not running.

Keyboard: CMStorm (no additional software installed) Currently Karabiner version: 0.90.86 macOS: 10.12.3

markschwarz commented 7 years ago

I'm uninstalling, too, until this thread wraps up. I'm seeing this behavior roughly 2x week, most often after coming back from sleep (which might just be a type of high load condition). If there's logging I can enable to rule out Karabiner, I'll try it!

I love using my Caps key for vim escape. I'll miss this.

This SO overflow seems loosely related: https://apple.stackexchange.com/questions/13708/disabling-the-keep-pressed-function-of-os-x-sticky-keys

codyrobbins commented 7 years ago

The issue is definitely related to CPU load—on a newer machine it rarely occurs but on an older 2010 MacBook Air it happens almost constantly when the CPU has a load and it makes Karabiner unusable.

EleanorRagone commented 7 years ago

@tekezo any update here? Anything we can do to help out? This has become completely unusable for me =/

SConaway commented 7 years ago

Same here MBP 15" Mid '14

jessejanderson commented 7 years ago

This is really becoming unusable. I'm completely reliant on having my Caps = Ctrl/Esc otherwise I would uninstall this. Currently, I just have come to expect 1-2 catastrophic key repeats every day now where a sticky key will do something like CMD-Q every single app I have open.

Any sort of update would be appreciated.

codyrobbins commented 7 years ago

Is a full list of previous releases available somewhere? I was going to try reinstalling previous releases to try to narrow down the release that introduced this problem, in the hope that it would help make the fix more obvious for @tekezo, but I don’t see any way to get the previous releases easily unfortunately.

daniula commented 7 years ago

@jessejanderson You can remap Caps to Ctrl/Esc without Karabiner. This dialog opens up after clickin "Modifier Keys…"

screen shot 2017-03-17 at 21 03 54

I'm using Karabiner only to remap £ with ~ on my EU keyboard. Not a big deal, so I keep it uninstalled until it's fixed.

jessejanderson commented 7 years ago

@daniula thanks but I actually need Karabiner to map Caps to Ctrl AND Esc. Tapping the key = Esc, holding the key as a modifier = Ctrl.

oleander commented 7 years ago

Any news on this one? Having the same problem :/

jerzygangi commented 7 years ago

Also having this problem.

markschwarz commented 7 years ago

I'd totally overlooked the Mac Keyboard menu shortcut, @daniula. That does everything I need: Caps->Esc. Thanks!

wcpines commented 7 years ago

@tekezo Should this issue be merged with #739 ?

mmmulani commented 7 years ago

it might be useful to run sample karabiner-grabber 1 during the time when it is repeating, so we can figure out what karabiner is doing. Trying to find a way now to automate this

mmmulani commented 7 years ago

so I did that and got this stack, which looks interesting:

basically IOHIDDeviceSetValue is taking a long time to return, it looks like from here: https://github.com/tekezo/Karabiner-Elements/blob/master/src/share/human_interface_device.hpp#L637

which perhaps is blocking some other calls in Karabiner-Elements. @tekezo any ideas here?

Analysis of sampling karabiner_grabber (pid 49) every 1 millisecond
Process:         karabiner_grabber [49]
Path:            /Library/Application Support/org.pqrs/Karabiner-Elements/bin/karabiner_grabber
Load Address:    0x1036eb000
Identifier:      karabiner_grabber
Version:         0
Code Type:       X86-64
Parent Process:  launchd [1]

Date/Time:       2017-06-20 13:18:16.636 -0700
Launch Time:     2017-06-15 12:00:28.503 -0700
OS Version:      Mac OS X 10.12.5 (16F2073)
Report Version:  7
Analysis Tool:   /usr/bin/sample
----

Call graph:
    4610 Thread_767   DispatchQueue_1: com.apple.main-thread  (serial)
    + 4610 start  (in libdyld.dylib) + 1  [0x7fff93c15235]
    +   4610 main  (in karabiner_grabber) + 774  [0x1036ec424]
    +     4610 CFRunLoopRun  (in CoreFoundation) + 97  [0x7fff7e4acb91]
    +       4610 CFRunLoopRunSpecific  (in CoreFoundation) + 420  [0x7fff7e46d114]
    +         3609 __CFRunLoopRun  (in CoreFoundation) + 2205  [0x7fff7e46dc0d]
    +         ! 3609 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__  (in CoreFoundation) + 9  [0x7fff7e4acbc9]
    +         !   3609 _dispatch_main_queue_callback_4CF  (in libdispatch.dylib) + 505  [0x7fff93bec908]
    +         !     3609 _dispatch_source_invoke  (in libdispatch.dylib) + 1248  [0x7fff93be213b]
    +         !       3609 _dispatch_source_latch_and_call  (in libdispatch.dylib) + 194  [0x7fff93beaa6c]
    +         !         3609 _dispatch_continuation_pop  (in libdispatch.dylib) + 533  [0x7fff93bf4a16]
    +         !           3609 _dispatch_client_callout  (in libdispatch.dylib) + 8  [0x7fff93bdf8fc]
    +         !             3609 krbn::device_grabber::update_caps_lock_led(bool)  (in karabiner_grabber) + 49  [0x1037058ff]
    +         !               3609 krbn::human_interface_device::set_caps_lock_led_state(krbn::led_state)  (in karabiner_grabber) + 228  [0x103705b44]
    +         !                 3601 ___ZN4krbn22human_interface_device23set_caps_lock_led_stateENS_9led_stateE_block_invoke  (in karabiner_grabber) + 162  [0x103705c7a]
    +         !                 : 3601 IOHIDDeviceSetValue  (in IOKit) + 33  [0x7fff803fd5d6]
    +         !                 :   3601 IOHIDDeviceClass::setElementValue(__IOHIDElement*, __IOHIDValue*, unsigned int, void (*)(void*, int, void*, __IOHIDValue*), void*, unsigned int)  (in IOHIDLib) + 249  [0x1038a24a7]
    +         !                 :     3601 IOConnectCallScalarMethod  (in IOKit) + 111  [0x7fff803cc47d]
    +         !                 :       3601 io_connect_method  (in IOKit) + 375  [0x7fff80446c91]
    +         !                 :         3601 mach_msg  (in libsystem_kernel.dylib) + 55  [0x7fff93d3b797]
    +         !                 :           3601 mach_msg_trap  (in libsystem_kernel.dylib) + 10  [0x7fff93d3c34a]
    +         !                 8 ___ZN4krbn22human_interface_device23set_caps_lock_led_stateENS_9led_stateE_block_invoke  (in karabiner_grabber) + 244  [0x103705ccc]
    +         !                   7 void spdlog::logger::log<char [88], int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(spdlog::level::level_enum, char const*, char const (&) [88], int const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)  (in karabiner_grabber) + 170  [0x10370651a]
    +         !                   | 6 spdlog::logger::flush()  (in karabiner_grabber) + 29  [0x1036eceb1]
    +         !                   | + 6 fflush  (in libsystem_c.dylib) + 40  [0x7fff93c87c83]
    +         !                   | +   6 __sflush  (in libsystem_c.dylib) + 87  [0x7fff93c87d27]
    +         !                   | +     6 _swrite  (in libsystem_c.dylib) + 87  [0x7fff93c8f201]
    +         !                   | +       6 __write_nocancel  (in libsystem_kernel.dylib) + 10  [0x7fff93d4447e]
    +         !                   | 1 spdlog::logger::_sink_it(spdlog::details::log_msg&)  (in karabiner_grabber) + 27  [0x1036ecedb]
    +         !                   |   1 spdlog::pattern_formatter::format(spdlog::details::log_msg&)  (in karabiner_grabber) + 64  [0x1036ebd76]
    +         !                   |     1 localtime_r  (in libsystem_c.dylib) + 41  [0x7fff93ca1844]
    +         !                   |       1 _st_tzset_basic  (in libsystem_c.dylib) + 50  [0x7fff93c9ff0b]
    +         !                   |         1 getenv  (in libsystem_c.dylib) + 29  [0x7fff93caa612]
    +         !                   |           1 os_unfair_lock_lock  (in libsystem_platform.dylib) + 10  [0x7fff93e27342]
    +         !                   1 void spdlog::logger::log<char [88], int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >(spdlog::level::level_enum, char const*, char const (&) [88], int const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)  (in karabiner_grabber) + 151  [0x103706507]
    +         !                     1 fmt::BasicWriter<char>::write(fmt::BasicCStringRef<char>, fmt::ArgList)  (in karabiner_grabber) + 0  [0x1036ef69e]
    +         1001 __CFRunLoopRun  (in CoreFoundation) + 1361  [0x7fff7e46d8c1]
    +           1001 __CFRunLoopServiceMachPort  (in CoreFoundation) + 212  [0x7fff7e46e434]
    +             1001 mach_msg  (in libsystem_kernel.dylib) + 55  [0x7fff93d3b797]
    +               1001 mach_msg_trap  (in libsystem_kernel.dylib) + 10  [0x7fff93d3c34a]
nicksergeant commented 7 years ago

I started seeing this issue directly after updating to beta 0.91.8. Similar to @jessejanderson, I have caps acting as control while down, and esc if pressed and released. Maybe that contributes to the issue.

stouf commented 7 years ago

I'm frequently experimenting the issue as well on my MacBook Pro 15" (2015), Mac OS 10.12.6. This can be quite scary to be honest, especially when typing in applications where mistyping something can be fatal (remote servers, etc...). To the contributors and maintainers, don't hesitate to ask for help here :)

onfoot commented 7 years ago

Happens to me too. Issue is gone as soon as I quit karabiner-elements.

It's also annoying when hitting CMD-Q which might seemingly cause a spike in CPU usage, causing Q to be repeated at least once.

tom-seddon commented 7 years ago

Hardware: Macbook Pro 12,1; Sierra 10.12.6; MS Natural 4000 USB (I've got two and it affects both)

I've been having this too. I used Karabiner-Elements to remap Right Application key to Right Command key, for use with my MS Natural 4000. No other settings.

One thing I did try: I set Karabiner-Elements to only remap the USB keyboard - the Macbook Pro's onboard keyboard already has 2 command keys of course! - but I still had the problem.

P.S. I'm lost with my right-hand Command key, since I mouse left-handed, but I discovered you can use the new Sierra hidutil tool if all you want is to remap some keys. So I made an Automator app for myself, to replace my use of Karabiner-Elements: https://github.com/tom-seddon/RemapApplicationKey. Might be of interest as an example for anybody else that uses Karabiner-Elements for simple remappings.

anuragvickey commented 7 years ago

This is still a problem. I am consistently seeing it on Mac OS X Sierra 10.12.6

Any update on the fix please?

davfox commented 7 years ago

I'm seeing same problem with 11.0.0 and MacOS 10.12.6. Started using Karabiner-Elements in May 2017 and it's happens one or twice a day. I no longer panic but know to expect last key typed to repeat 20-30 times and then it stops. I keep installing updates expecting it to go away but it hasn't in 4 months.

For me it doesn't appear to be linked to high CPU load though.

onfoot commented 7 years ago

Thanks so much @tom-seddon for pointing out the Apple document. I created a remap script using the hditool, added a service that's run on login and was able to remove Karabiner-Elements completely.

The key repeat issue was too annoying to deal with any more. Just like @davfox, I've been constantly updating Karabiner-Elements with the hope that the new release finally fixes it.

xianghui commented 7 years ago

Is there a way to map the EJECT/POWER key on a mac keyboard? missed doing CTRL+ EJECT to shutdown (CTRL+SHIFT+EJECT to sleep)

Thanks

wcpines commented 6 years ago

Still seeing this issue as well. My mapping is CAPS => BS.

jiehanzheng commented 6 years ago

Experiencing this as well; under high CPU load, pressing Volume Up key once will turn up the volume by many notches

aflat commented 6 years ago

I hit this even when cpu load isn't high. Just every day usage. Oddly enough, I work around it by quitting KE. I don't restart KE. It seems to keep the VirtualHIDKeyboard around, so my key mappings mostly work. I'm a PC convert(converted about 10 years ago) so I have basic ctrl+c ctrl+v(plus a few others) and I remap fn to crtl. This all works with KE up, even on a USB macally keyboard. When I quit KE, I don't get the repeated keys, or the unregistered keystrokes(I type nothing prints to the screen, probably related), but my windows mappings still stick, and fn is still remapped to ctrl. Unfortunately, ctrl gets remapped to fn when I quit, and macally doesn't have a fn key, so ctrl doesn't work right on that keyboard. So it seems like the VirtualHIDKeyboard is doing things fine, and since the karabiner_grabber is still running(even though I quit KE), it seems to be doing ok.

pei416 commented 6 years ago

I have the same problem, high CPU load and very lag.

sicher commented 6 years ago

I was getting unexpected key repeats daily as well on my external keyboard. No idea if that was during high load or not. But I ditched KE a month ago and it has not happened once since then.

braham-snyder commented 6 years ago

Though I too would love to see this bug fixed (I have not yet upgraded from El Capitan because I find Karabiner that useful), "+1"-style posts send every subscriber a notification -- I (and I suspect many other subscribers) would greatly appreciate it if everyone instead gave the OP a thumbs up (by clicking the smiley face in its top right corner).

(For those who haven't ran into it: GitHub's issue tracker can sort issues by the numbers of reactions they've each garnered -- ideally, IMO, we'd have explicit issue voting with votes displayed next to the number of comments as in https://github.com/isaacs/github/issues/9, but unfortunately that doesn't look like it will happen in the near future.)

AndiDog commented 6 years ago

This seems to be happening even for automated keystrokes 😳 as done by packer for setting up virtual machines.

losipiuk commented 6 years ago

@tekezo Are you working on this issue maybe? I observe it too, only with Karabiner-Elements enabled. Karabiner-Elements is great piece of software generally - thanks a lot for giving that away. Yet this issue renders it hardly usable for a long run :/

ignaciovazquez commented 6 years ago

Happens here too

nicksergeant commented 6 years ago

I wanted to chime in here again because I'm still seeing this issue after completely uninstalling Karabiner-Elements. It doesn't seem to happen as often, but it does happen. I'm wondering if it's related to using a Bluetooth keyboard (or just bluetooth interference causing issues), or possibly Keyboard Maestro, which I'm also using.

This seems to be a very common issue with Windows PCs: https://social.technet.microsoft.com/Forums/windows/en-US/a2c20718-643e-4d2a-8507-0930295c1d2d/keys-repeat-uncontrollably?forum=w7itprohardware