9

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"

Hatshepsut
  • 545
  • 3
  • 14
  • @phils How do I check? – Hatshepsut Aug 20 '19 at 00:15
  • 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 '19 at 00: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 '19 at 00: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 '19 at 03: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 '19 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 '19 at 15:50
  • Re 26.2, I've had this happen with GNU-Emacs-26.3/GTK+-3.24 (on Ubuntu-20.04/GNU/Linux/amd64) - with which the `ibus` answer by mikael-s worked for me. – Randall Whitman Dec 30 '22 at 16:14
  • @nega Thanks! I'm having a similar issue with a much recent version of Emacs (Emacs 30, built from Git, running on Wayland with pgtk), and your command fixed it for me: hitting `TAB` did it :) Next time it happens I'll try to jump into a debugger to understand how to really fix it. – Schnouki Feb 23 '23 at 11:34

1 Answers1

7

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
mikael-s
  • 311
  • 2
  • 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 '21 at 21:22
  • Huh, in 2023 in Emacs 29.1 this still happens and this fixed it – Joseph Garvin Aug 24 '23 at 23:50