Subject: 29.0.50; Unreliable input-pending-p and throw-on-input on Emacs 29 / pgtk in Wayland

From: Vijay Marupudi <[email-masked]>
Date: Wed, 11 May 2022 08:34:56 -0500

Hello,

I would like to report an inconsistency issue with how pending input is
communicated with elisp code. In Emacs 29, input-pending-p sometimes
returns t and while-no-input is interrupting code (because it uses
throw-on-input) AFTER all keyboard input has already been read into
elisp code and is being processed, and when there is no pending input.
This is leading to code being unable to process and react to the latest
input because it gets interrupted while handling the latest input.

This issue does not occur in X.Org sessions, only Wayland.

This issue was initially encountered via the vertico ELPA package, for
more discussion and screencasts, see here.

https://github.com/minad/vertico/issues/226#issuecomment-1123087263

To replicate this bug, run this code, and then type very fast on your
keyboard. When I type the string "not" very fast, the printed message is
`"not", t`

(require 'cl-lib)

(defun my-hook ()
  (message "%S, %S" (minibuffer-contents)
           (while-no-input
             (cl-loop for i from 0 below 1000000
                      summing i))))

(minibuffer-with-setup-hook (lambda ()
                              (add-hook 'post-command-hook
                                        'my-hook
                                        nil t))
  (read-from-minibuffer "Text: "))

Setup information:

In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.17.6)
 of 2022-05-10 built on entropy
Repository revision: 430b5ba838f31865139e3a724f9191e2b1de57d1
Repository branch: master
System Description: Arch Linux

Configured using:
 'configure --with-json --with-pgtk --with-native-compilation
 --with-xinput2 --with-file-notification=inotify --with-mailutils'

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

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=ibus
  locale-coding-system: utf-8-unix

Major mode: Messages

Minor modes in effect:
  global-company-mode: t
  company-mode: t
  which-key-mode: t
  pdf-occur-global-minor-mode: t
  savehist-mode: t
  recentf-mode: t
  marginalia-mode: t
  vertico-mode: t
  show-smartparens-global-mode: t
  global-git-commit-mode: t
  magit-auto-revert-mode: t
  shell-dirtrack-mode: t
  override-global-mode: t
  global-auto-revert-mode: t
  delete-selection-mode: t
  global-display-line-numbers-mode: t
  display-line-numbers-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  buffer-read-only: t
  size-indication-mode: t
  column-number-mode: t
  line-number-mode: t
  global-visual-line-mode: t
  visual-line-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/home/vijaymarupudi/.emacs.d/elpa/transient-20220509.1943/transient hides /usr/local/share/emacs/29.0.50/lisp/transient

Features:
(shadow sort mail-extr emacsbug misearch multi-isearch vc-mtn vc-hg
vc-git vc-bzr vc-src vc-sccs vc-svn vc-cvs vc-rcs log-view vc
vc-dispatcher vertico-directory mule-util vj-notmuch-config vj-diff
company-oddmuse company-keywords company-etags company-gtags
company-dabbrev-code company-dabbrev company-files company-clang
company-capf company-cmake company-semantic company-template
company-bbdb company cape vj-wiki vj-elisp vj-capture bbt which-key
typescript-mode cc-mode-expansions smartparens-c cc-mode cc-fonts
cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs
lsp-pyright pdf-occur ibuf-ext ibuffer ibuffer-loaddefs tablist
tablist-filter semantic/wisent/comp semantic/wisent
semantic/wisent/wisent semantic/util-modes semantic/util semantic
semantic/tag semantic/lex semantic/fw mode-local find-func cedet
pdf-isearch let-alist pdf-misc pdf-loader pdf-tools pdf-view jka-compr
pdf-cache pdf-info pdf-util pdf-macs image-mode exif lsp-mode
lsp-protocol spinner network-stream nsm lv inline ht f s ewoc slime
arc-mode archive-mode hyperspec geiser-guile info-look geiser
geiser-repl geiser-compile geiser-debug compile geiser-image geiser-capf
geiser-doc geiser-menu geiser-edit etags fileloop generator xref project
geiser-completion geiser-autodoc geiser-eval geiser-connection tq
geiser-syntax scheme geiser-log geiser-popup view ein
smartparens-markdown markdown-mode color noutline outline savehist
embark-consult consult-vertico consult compat-28 recentf tree-widget
magit-bookmark bookmark notmuch notmuch-tree notmuch-jump notmuch-hello
notmuch-show notmuch-print notmuch-crypto notmuch-mua notmuch-message
notmuch-draft notmuch-maildir-fcc notmuch-address notmuch-company
notmuch-parser notmuch-wash coolj notmuch-query goto-addr icalendar
diary-lib diary-loaddefs cal-menu calendar cal-loaddefs notmuch-tag
notmuch-lib notmuch-version notmuch-compat hl-line mm-view mml-smime
smime gnutls dig vj-embark embark ffap marginalia orderless vertico
expand-region text-mode-expansions er-basic-expansions
expand-region-core expand-region-custom smartparens-config
smartparens-text smartparens advice rainbow-delimiters magit-submodule
magit-obsolete magit-blame magit-stash magit-reflog magit-bisect
magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit
magit-sequence magit-notes magit-worktree magit-tag magit-merge
magit-branch magit-reset magit-files magit-refs magit-status magit
magit-repos magit-apply magit-wip magit-log which-func imenu magit-diff
smerge-mode diff diff-mode git-commit log-edit message eudc-capf eudc
cus-edit pp cus-load eudc-vars sendmail yank-media rmc dired
dired-loaddefs rfc822 mml mml-sec epa derived epg rfc6068 epg-config
mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045
ietf-drums mailabbrev gmm-utils mailheader pcvs-util add-log magit-core
magit-autorevert magit-margin magit-transient magit-process with-editor
shell pcomplete comint ansi-color magit-mode transient edmacro kmacro
magit-git magit-base magit-section format-spec crm dash compat-27
compat-26 compat exec-path-from-shell eww xdg url-queue thingatpt shr
pixel-fill kinsoku url-file url-dired svg dom puny mm-url gnus nnheader
gnus-util text-property-search time-date mail-utils range wid-edit
mm-util mail-prsvr notifications dbus xml use-package use-package-ensure
use-package-delight use-package-diminish use-package-bind-key bind-key
easy-mmode use-package-core modus-operandi-theme modus-themes pcase
autorevert filenotify delsel display-line-numbers comp comp-cstr
warnings rx cl-extra server geiser-impl help-fns radix-tree help-mode
geiser-custom geiser-base ring slime-autoloads info package browse-url
url url-proxy url-privacy url-expand url-methods url-history url-cookie
url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq
eieio eieio-core cl-macs eieio-loaddefs password-cache json map url-vars
seq gv subr-x byte-opt bytecomp byte-compile cconv cl-loaddefs cl-lib
iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/pgtk-win pgtk-win term/common-win
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
simple cl-generic 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 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 dbusbind inotify dynamic-setting system-font-setting
font-render-setting cairo gtk pgtk lcms2 multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 542628 440465)
 (symbols 48 42850 1)
 (strings 32 143837 32615)
 (string-bytes 1 6262187)
 (vectors 16 75716)
 (vector-slots 8 1324303 604428)
 (floats 8 410 1561)
 (intervals 56 1363 434)
 (buffers 992 17))