Subject: bug#63187: 30.0.50; Tail of longer lines painted after end of nearby lines on macOS

From: Po Lu <[email-masked]>
Date: Sun, 30 Apr 2023 21:25:38 +0800

Aaron Jensen <[email-masked]> writes:

> I don't have a good recipe for this. It has been happening occasionally
> for quite some time (the attached screenshots are from 2021, but the
> same thing is still occurring). Every once in a while, a part of the
> Emacs frame gets into a state where glyphs from nearby lines can be
> painted after the tail end of other lines. This seems to be related to
> scrolling (that is, while scrolling, the glyphs replicate onto nearby
> lines, but when scrolling back they stay. I usually have to force a full
> repaint to get the glyphs to disappear.
>
>
>
>
>
>
> In GNU Emacs 30.0.50 (build 1, aarch64-apple-darwin22.4.0, NS
>  appkit-2299.50 Version 13.3.1 (Build 22E261)) of 2023-04-09 built on
>  Aarons-Laptop.local
> Windowing system distributor 'Apple', version 10.3.2299
> System Description:  macOS 13.3.1
>
> Configured using:
>  'configure --disable-dependency-tracking --disable-silent-rules
>  --enable-locallisppath=/opt/homebrew/share/emacs/site-lisp
>  --infodir=/opt/homebrew/Cellar/emacs-plus@30/30.0.50/share/info/emacs
>  --prefix=/opt/homebrew/Cellar/emacs-plus@30/30.0.50 --with-xml2
>  --with-gnutls --with-native-compilation --without-compress-install
>  --without-dbus --without-imagemagick --with-modules --with-rsvg
>  --with-ns --disable-ns-self-contained 'CFLAGS=-Os -w -pipe
>  -mmacosx-version-min=13
>  -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk
>  -DFD_SETSIZE=10000 -DDARWIN_UNLIMITED_SELECT'
>  'CPPFLAGS=-I/opt/homebrew/opt/zlib/include
>  -I/opt/homebrew/opt/jpeg/include -I/opt/homebrew/opt/icu4c/include
>  -I/opt/homebrew/opt/[email-masked]/include -isystem/opt/homebrew/include
>  -F/opt/homebrew/Frameworks
>  -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk'
>  'LDFLAGS=-L/opt/homebrew/opt/zlib/lib -L/opt/homebrew/opt/jpeg/lib
>  -L/opt/homebrew/opt/icu4c/lib -L/opt/homebrew/opt/[email-masked]/lib
>  -L/opt/homebrew/lib -F/opt/homebrew/Frameworks
>  -Wl,-headerpad_max_install_names
>  -isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk''
>
> Configured features:
> ACL GIF GLIB GMP GNUTLS JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP
> NOTIFY KQUEUE NS PDUMPER PNG RSVG SQLITE3 THREADS TIFF
> TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XIM ZLIB
>
> Important settings:
>   value of $LANG: en_US.UTF-8
>   locale-coding-system: utf-8-unix
>
> Major mode: ELisp/d
>
> Minor modes in effect:
>   global-evil-mc-mode: t
>   evil-mc-mode: t
>   treemacs-filewatch-mode: t
>   treemacs-follow-mode: t
>   treemacs-git-mode: t
>   treemacs-fringe-indicator-mode: t
>   global-git-commit-mode: t
>   transient-posframe-mode: t
>   windmove-mode: t
>   global-flycheck-mode: t
>   flycheck-mode: t
>   gcmh-mode: t
>   undo-fu-session-global-mode: t
>   undo-fu-session-mode: t
>   ws-butler-global-mode: t
>   ws-butler-mode: t
>   ns-auto-titlebar-mode: t
>   global-anzu-mode: t
>   anzu-mode: t
>   corfu-prescient-mode: t
>   corfu-history-mode: t
>   corfu-mode: t
>   form-feed-mode: t
>   eval-sexp-fu-flash-mode: t
>   eros-mode: t
>   lispyville-mode: t
>   lispy-mode: t
>   elisp-def-mode: t
>   sotlisp-mode: t
>   speed-of-thought-mode: t
>   electric-pair-mode: t
>   envrc-mode: t
>   global-evil-surround-mode: t
>   evil-surround-mode: t
>   evil-matchit-mode: t
>   evil-vimish-fold-mode: t
>   vimish-fold-mode: t
>   dtrt-indent-mode: t
>   tabspaces-mode: t
>   save-place-mode: t
>   winner-mode: t
>   savehist-mode: t
>   delete-selection-mode: t
>   yas-global-mode: t
>   yas-minor-mode: t
>   vertico-prescient-mode: t
>   prescient-persist-mode: t
>   vertico-mouse-mode: t
>   vertico-mode: t
>   mini-frame-mode: t
>   better-jumper-mode: t
>   better-jumper-local-mode: t
>   xterm-mouse-mode: t
>   pixel-scroll-precision-mode: t
>   global-auto-revert-mode: t
>   which-key-posframe-mode: t
>   which-key-mode: t
>   org-roam-db-autosync-mode: t
>   shell-dirtrack-mode: t
>   recentf-mode: t
>   repeat-mode: t
>   +popup-mode: t
>   evil-mode: t
>   evil-local-mode: t
>   nano-modeline-mode: t
>   server-mode: t
>   leader-key-leader-override-mode: t
>   global-leader-key-leader-override-mode: t
>   elpaca-use-package-mode: t
>   override-global-mode: t
>   global-display-line-numbers-mode: t
>   display-line-numbers-mode: t
>   global-eldoc-mode: t
>   eldoc-mode: t
>   show-paren-mode: t
>   electric-indent-mode: t
>   mouse-wheel-mode: t
>   tab-bar-mode: t
>   file-name-shadow-mode: t
>   global-font-lock-mode: t
>   font-lock-mode: t
>   window-divider-mode: t
>   line-number-mode: t
>   auto-fill-function: yas--auto-fill
>   transient-mark-mode: t
>   auto-composition-mode: t
>   auto-encryption-mode: t
>   auto-compression-mode: t
>   abbrev-mode: t

Hmmm, this looks like a scrolling optimization bug.
I can't build the NS port right now, but if you insert:

  return false;

right after

  /* Can't scroll the display of w32 GUI frames when position of point
     is indicated by the system caret, because scrolling the display
     will then "copy" the pixels used by the caret.  */
#ifdef HAVE_NTGUI
  if (w32_use_visible_system_caret)
    return 0;
#endif

in `scrolling_window', in dispnew.c, does the problem go away?