Subject: 30.0.50; persistent key input delay after using vc commands in pgtk

From: Nick OBrien <[email-masked]>
Date: Sat, 17 Feb 2024 20:38:06 +0000

After opening a file in a git repository with emacs -Q, using vc-annotate, and
returning to the file, various key inputs like C-f, C-b, and typing characters
have a noticeable delay between key down and screen update. I am using GNOME
45.3 and Wayland.

Steps to reproduce (starting from an empty directory):

$ git init
$ seq 10 > foo
$ git add -A && git commit -m 'c1'
$ seq 10 >> foo
$ git add -A && git commit -m 'c2'
$ seq 10 >> foo
$ git add -A && git commit -m 'c3'
$ emacs -Q

C-x C-f foo RET
C-f C-b ; no noticeable delay
C-x v g
p p n n
C-x k RET
C-f C-b ; noticeable delay

After following those steps, pressing and holding C-f does not visually update
the cursor until 100s of milliseconds later (although occasionally it would
update immediately). However, the cursor would also be updated as soon as C-f
was released. Before running C-x v g, holding C-f would immediately update the
cursor.

Setting the following did not have a noticeable effect:

(setq pgtk-wait-for-event-timeout 0)

After starting a daemon with M-x server-start (from the same emacs as before)
and opening a terminal client with emacsclient -nw, holding down C-f in the foo
buffer immediately updated the cursor, just like in the graphical client before
running C-x v g.

Context:

This delay has been happening to me for a while when using emacs 29 pgtk and
magit. My emacs will start with no key input delay, and then after a while of
editing and doing various magit commands, key inputs would suddenly have the
delay described above after running a particular magit command. The delay would
happen in every buffer. It would persist for the entire life of the emacs
process, even after running desktop-clear, disabling most global minor modes,
closing and re-opening the emacs client window, etc. Like described above,
terminal clients would not have the input lag even when graphical clients did. I
was able to more reliably reproduce this lag when using vc. Although my steps to
reproduce this bug use vc-annotate, I experienced the bug when making commits
with vc as well.

Software information from GNOME settings:
- **Firmware Version:**                            H.F0
- **OS Name:**                                     NixOS 23.11 (Tapir)
- **OS Build:**                                    23.11.20240211.809cca7
- **OS Type:**                                     64-bit
- **GNOME Version:**                               45.3
- **Windowing System:**                            Wayland
- **Kernel Version:**                              Linux 6.1.77

In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.39, cairo version 1.18.0)
Repository revision: 77576cd7626e4a99a5c88aa854091d701edd53a8
Repository branch: master
System Description: NixOS 23.11 (Tapir)

Configured using:
 'configure
 --prefix=/nix/store/yv9dl9jplhk8pgjkkp1qrpp5mw99524r-emacs-pgtk-20240217.0
 --disable-build-details --with-modules --with-pgtk
 --with-native-compilation --with-tree-sitter --with-xwidgets'

Configured features:
CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON
LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER
PGTK PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
TREE_SITTER WEBP XIM XWIDGETS GTK3 ZLIB

Important settings:
  value of $EMACSLOADPATH: 
  value of $EMACSNATIVELOADPATH: 
  value of $LC_MONETARY: en_US.UTF-8
  value of $LC_NUMERIC: en_US.UTF-8
  value of $LC_TIME: en_US.UTF-8
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=fcitx
  locale-coding-system: utf-8-unix

Major mode: Fundamental

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util text-property-search mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils iso8601 time-date
subr-x help-mode vc-annotate vc vc-git diff-mode easy-mmode
vc-dispatcher cl-loaddefs cl-lib rmc iso-transl tooltip cconv eldoc
paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode
mwheel term/pgtk-win pgtk-win term/common-win pgtk-dnd tool-bar dnd
fontset image regexp-opt fringe tabulated-list replace newcomment
text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow
isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax
font-core term/tty-colors frame minibuffer nadvice seq simple cl-generic
indonesian philippine cham georgian utf-8-lang misc-lang vietnamese
tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
composite emoji-zwj charscript charprop case-table epa-hook
jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs
theme-loaddefs faces cus-face macroexp files window text-properties
overlay sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads xwidget-internal dbusbind
inotify dynamic-setting system-font-setting font-render-setting cairo
gtk pgtk multi-tty move-toolbar make-network-process native-compile
emacs)

Memory information:
((conses 16 60720 9114) (symbols 48 6128 0) (strings 32 17189 2899)
 (string-bytes 1 599226) (vectors 16 10446)
 (vector-slots 8 145248 6672) (floats 8 36 525) (intervals 56 268 14)
 (buffers 984 12))