11

Sometimes Emacs stops responding to keyboard input. It responds to mouse input though. If I do killall -s SIGUSR2 emacs, the debugger shows this (but remains unresponsive to keyboard):

Debugger entered--entering a function:
* company-pre-command()
  recursive-edit()
  debug(lambda)
* company-pre-command()
  recursive-edit()
  debug(lambda)
* eldoc-pre-command-refresh-echo-area()

This happens every few days and I end up having to kill emacs and restart. How can I fix it?


GNU Emacs 26.1 running emacsclient

Ubuntu 18.04

system-configuration-options: "--build=x86_64-linux-gnu --prefix=/usr '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' --sysconfdir=/etc --localstatedir=/var --disable-silent-rules '--libdir=${prefix}/lib/x86_64-linux-gnu' '--libexecdir=${prefix}/lib/x86_64-linux-gnu' --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --sharedstatedir=/var/lib --program-suffix=26 --with-modules --with-file-notification=inotify --with-mailutils --with-x=yes --with-x-toolkit=gtk3 --with-xwidgets --with-lcms2 'CFLAGS=-g -O2 -fdebug-prefix-map=/build/emacs26-pCvJBp/emacs26-26.1~1.git07f8f9b=. -fstack-protector-strong -Wformat -Werror=format-security -no-pie' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro -no-pie'"

system-configuration-features: "XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 MODULES THREADS XWIDGETS LIBSYSTEMD LCMS2"

8
  • 2
    I've encountered this on a handful of occasions (certainly not as frequently as yourself). For me it affected GUI frames only, so emacsclient -nw still takes keyboard input. You may be able to restore GUI functionality by creating a terminal frame and then deleting all other frames, and only then creating a new GUI frame -- I'm not 100% sure of that process though, as my results were inconsistent. If the server was started with emacs --daemon then you may need to delete the (hidden) frame which was created when the daemon started.
    – phils
    Aug 20, 2019 at 0:20
  • 1
    I'm not sure I've seen this with 26.2 come to think of it, so potentially a solution is to upgrade.
    – phils
    Aug 20, 2019 at 0:22
  • 1
    FWIW I compile --with-x-toolkit=lucid and you're using gtk3 so presumably the issue is not specific to any particular X toolkit.
    – phils
    Aug 20, 2019 at 3:53
  • 1
    This smells like a UI bug. If I were to guess, a popup window (window in the UI sense) is being instantiated, but not actually rendered, cutting off your ability to dismiss it. Based on your debug output, it's possibly a company completion popup. Try disabling these popups, If the frequency of your freezes decreases, great, we're on the right track. If not, then I was totally wrong. ;)
    – nega
    Aug 20, 2019 at 15:46
  • 1
    If a freeze happens in a situation where you'd expect a company popup, try to complete a completion by hitting TAB or RET or whatever you've configured. (I assume you've already done this as those are the first keys I'd mash)
    – nega
    Aug 20, 2019 at 15:50

2 Answers 2

17

I had the same issue for years. It actually seems (at least in my case) to be an IBus issue (IBus allows to input multiple languages).

When the keyboard stops responding in Emacs, typing that command in the console solves the problem. It restarts (-r) IBus daemon(-d). I found the solution here.

ibus-daemon --xim -d -r
6
  • I can't recall experiencing this problem myself in more recent times, but I'm taking a note of this so that I can try it if it ever happens to me again. Do you have any insight into whether this an Emacs bug is triggering this?
    – phils
    Nov 15, 2021 at 21:22
  • 3
    Huh, in 2023 in Emacs 29.1 this still happens and this fixed it Aug 24, 2023 at 23:50
  • I second @JosephGarvin. I have never seen this until now, and the ibus command worked. For what it's worth, it seemed to happen to me when I opened a frame using emacsclient. Jan 3 at 12:45
  • I had the same problem appearing this week. IBus command worked. Are there any more permanent solutions?
    – MCSH
    Mar 31 at 13:33
  • 1
    Curiously I almost never experienced this problem … until I upgraded to emacs 29.3. Since then it happens fairly often (at least weekly). And ibus restart helps, thank you (I tried various things but never had idea to search in this direction).
    – Mekk
    Apr 12 at 14:43
1

Update: It seems that what I said earlier it didn't actually fix the problem, it just took a while to show up again.

TL;DR --- not sure why this is happening, but downgrading from emacs 29.3-1 => emacs 29.2-1 seems to be working as a temporary fix for me, though your mileage may vary. I also corrected some environment variables (I formerly had export GTK_IM_MODULE=fcitx5 and export QT_IM_MODULE=fcitx5 and replaced them both with fcitx) since fcitx5-diagnose said to do so, but I'm not sure if this contributed anything to my setup working again.

Longer version: I've been suddenly having this issue for the past week or so. In particular, it seems to happen most often (but still semi-unpredictably) when I'm trying to do C-c C-c commands, like compiling a doc in latex-mode and also when closing a commit message in magit.

Though I'm using fcitx5 instead of IBus, killing/restarting my input manager as detailed in the top answer seems to "work" for me, in the sense that after doing so I can interact with emacs via the keyboard again. Scare quotes because it's not really a permanent solution.

Since it seems to have just started happening a week or so ago (coinciding with when I upgraded from 29.2-1 => 29.3-1 on March 25th), and since it seems to be affecting people who use both fcitx5 and IBus, I would guess that there's some sort of bug here with emacs 29.3-1 itself --- though I want to be clear that I don't know much at all about the internals of emacs. Maybe someone else can provide more insight here.

2
  • I have the same issue, but downgrade to 29.2-1 doesn't solve the problem. Restart fcitx5 works.
    – godblessfq
    Apr 1 at 3:05
  • I guess the issue is with one of the dependencies of emacs.
    – godblessfq
    Apr 1 at 3:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.