justbur / emacs-which-key

Emacs package that displays available keybindings in popup
GNU General Public License v3.0
1.74k stars 87 forks source link

Emacs Freezes Before which-key Appears #252

Closed kevinjfoley closed 3 years ago

kevinjfoley commented 4 years ago

I've been having an issue the past few months with Emacs freezing right before the which-key dialog appears. I previously shared on Reddit.

I'm not certain that which-key is the cause of this but I've been unable to troubleshoot it properly and so I'm hoping to get some insight on what potential causes could be or how to rule which-key out.

Essentially, my Emacs GUI will freeze completely in between me hitting a prefix key and the which-key dialog appearing. I'm still able to access the Emacs server with emacsclient and can connect via a terminal frame but not a new GUI frame.

which-key works fine most of the time and I haven't been able to discern any kind of pattern behind when it happens.

I believe the issue started when I upgraded from 42a250 to 8b49ae. Right now I'm trying to confirm I don't have the issue on 42a250 and then start bisecting commits between the two to try to narrow things down.

Since I can reliably reproduce the issue this is a bit difficult so if there's anything you can suggest looking at/trying I'd be very grateful.

Other details:

valrus commented 4 years ago

I'm experiencing what seems to be this issue as well. FWIW I'm using Doom Emacs and the profiler reports this for CPU use (truncated to show where the bulk of the time is spent; columns are function / CPU samples / %)

- timer-event-handler                                            3054  84%
 - apply                                                         3054  84%
  - which-key--update                                            2916  80%
   - which-key--create-buffer-and-show                           2916  80%
    - which-key--get-bindings                                    2848  78%
     - which-key--format-and-replace                             2846  78%
      - which-key--maybe-replace                                 2804  77%
         which-key--match-replacement                             131   3%
       - which-key--get-pseudo-binding                              6   0%
        + kbd                                                       5   0%

Also on Mac OS 10.15.5, Emacs 27.0.91 from 2020-06-24.

rgrinberg commented 4 years ago

I think this is the same issues as #226

kevinjfoley commented 4 years ago

I think this is the same issues as #226

Just to clarify, this may be the case for the issue @valrus described but I think the issue I'm seeing is different. Emacs doesn't seem to have issue with resources being eaten up but rather the GUI becomes unresponsive. Connecting via terminal everything works fine.

Also and update, I moved from 42a250 to 1e3640e and confirmed I had the same issue again. Now trying dcb9820.

posobin commented 4 years ago

I am having the same problem. About once or twice a week emacs freezes when I hit some prefix (today it was SPC b), the minibuffer gets updated to SPC b- buffer [C-h paging/help], but the which key window does not appear and emacs doesn't visibly respond to SIGUSR2.

Interestingly, emacs does seem to respond to key presses (e.g. I can switch the full screen mode on or off), and one of the times before I had been able to observe the window title changing when pressing the keys to switch buffers, but the GUI is stuck. Plus I before I was able to observe the title change to the trace buffer opened by SIGUSR2, but of course can't see the contents as GUI is stuck, and didn't seem to be able to write it to the disk.

The only solution I have been able to find is to restart Emacs. I am using doom emacs, but this was happening when I was using spacemacs a month ago too. Emacs 27.1, MacOS 10.15.5.

posobin commented 4 years ago

Ah, I have been able to write the contents of the debugger buffer to file, it's just 2 lines:

Debugger entered--Lisp error: (quit)
  redisplay_internal\ \(C\ function\)()

One more thing: I pressed C-g immediately after pressing SPC b, not sure whether Emacs hung up right before or right after that.

kevinjfoley commented 3 years ago

I recently rolled back all of my packages to the last known working versions and confirmed that I no longer had the issue. Therefore I think this is related to a dependency or some other package and not which-key.

I'd recommend to anyone else having this issue to try updating all packages and see if that fixes things.