TeMPOraL / nyan-mode

Nyan Cat for Emacs! Nyanyanyanyanyanyanyanyanyan!
GNU General Public License v3.0
794 stars 68 forks source link

Disabling nyan-mode leaves an expensive timer running #45

Closed tmurph closed 4 years ago

tmurph commented 4 years ago

I noticed that Emacs was hitting my CPU pretty heavily and traced the problem back to a lingering nyan-animation-timer that was spinning despite my having disabled nyan-mode.

Steps to reproduce

Emacs version 26.3, nyan-mode 1.1.2

  1. Start up top, or your favorite CPU monitor.
  2. Start emacs -Q -l nyan-mode.el
  3. M-x nyan-mode
  4. Watch the emacs process use some CPU but quiet down to minimal usage (basically nothing on my laptop, just a few spikes every now and then).
  5. Evaluate (customize-set-variable 'nyan-animate-nyancat t)
  6. Watch the emacs process start consuming CPU. >3% on my laptop, though up to way more if I enable other heavyweight mode line constructs.
  7. M-x nyan-mode (disable nyan-mode)
  8. Watch the emacs process continue to consume CPU. >2% on my laptop, though still a lot if I enable other mode line constructs.
  9. M-x nyan-stop-animation
  10. Watch the process go back down to minimal CPU usage.

Expected behavior

CPU usage should stop when disabling nyan-mode.

Analysis

After step (9) above, M-x list-timers shows that the nyan-animation-timer is still spinning. This forces an expensive mode-line update every second. The problem is that the timer only gets canceled through customizing nyan-animate-nyancat, not through disabling the actual mode.