Subject: Re: bug#74541: 28.2; Emacs hangs every few seconds

From: Eli Zaretskii <[email-masked]>
Date: Tue, 26 Nov 2024 17:27:10 +0200

> Date: Tue, 26 Nov 2024 09:36:14 +0100
> From: Tobias Bora <[email-masked]>
> 
> Bug description: since I upgraded my system, emacs hangs regularly
> (usually every 10 seconds or so), during maybe 3 seconds on average. 
> Like just the time to write this bug report,
> emacs hanged 13 times frankly (more than a few seconds), and a few times
> I felt a bit of a lag when writting. The hang can
> occur while typing, or while moving (e.g. with ctrl+arrow
> left/right). The bug occurs also while starting emacs with -Q and with
> multiple versions (tested with 28.2 and 29.4). Funily enough, the bug
> started after I upgraded my system, but not emacs (emacs was installed
> via home-manager, and I upgraded first my system, then home-manager but
> still used emacs in the meantime). Note however that this bug is not
> specific to the emacs installed via home-manager, as the system-wide
> installed emacs also suffers from this bug. I am running KDE, and the
> bug was present in KDE Plasma 5 and 6, with both wayland and X11, and
> with both the lucid and gtk versions of emacs. Note
> also that emacs is the only application witnessing hangs. I run nixos 
> unstable,

Since you say that the issue began when you upgraded your system
without changing Emacs, I would suggest first to look into the changes
brought in by your system upgrade.  The fact that Emacs is the only
application you use which experiences these problems doesn't
necessarily mean the problem is in Emacs.  For example, Emacs might be
the only program you use that makes use of some system software which
causes this.

Searching in etc/PROBLEMS for "hangs" I found this entry:

  ** Emacs hangs when using XIM

  This is due to an old bug in the implementation of the X protocol's
  XIM transport: when an input method crashes for some reason, Xlib
  cannot recover.  Emacs cannot do anything about this except wait for
  input method developers to fix their crashes.  You can work around
  these problems by disabling XIM in your X resources:

    Emacs.useXIM: false

Could this be your problem?

If nothing else helps, make sure you have debug information for Emacs,
then attach a debugger when Emacs hangs, and post a backtrace here.
Maybe that will give us some clues.

It is also possible that a newer version of Emacs doesn't have this
problem.  The latest released Emacs version is 29.4, and Emacs 30.1 is
currently in pretest.  If you can try that, please do.