Subject: bug#79295: [Bug] Artifacts in margin with display-line-numbers-mode (relative)

From: Marco <[email-masked]>
Date: Sat, 23 Aug 2025 22:18:33 +0200

Description:

Hi, when using `display-line-numbers-mode` with relative numbering, 
scrolling a buffer sometimes produces
colored horizontal lines or dots in the line-number margin.

Steps to reproduce:
1. Start Emacs with GTK.
2. Enable relative line numbers:
    (setq display-line-numbers-type 'relative)
    (global-display-line-numbers-mode 1)
3. Scroll the buffer up and down.

Observed behavior:
- Horizontal bars or dots appear in the line-number margin while scrolling.
- Artifacts are colored (green/magenta/white on monitor) but screenshots 
show them as dark blue.
- Absolute line numbers render correctly without artifacts.

Environment:
- Emacs version: GNU Emacs 30.2 (build 2, x86_64-pc-linux-gnu, GTK+ 
Version 3.24.41, cairo version 1.18.0) of 2025-08-15

- GTK version: 3.24.41

- OS: Ubuntu 24.04 with Gnome and Wayland

- Theme: Dracula

Additional observations:
- The issue persists with GDK_DEBUG=nogl and GDK_BACKEND=x11.
- Forcing a solid background for 'line-number' and 
'line-number-current-line' mitigates the issue:
   (set-face-attribute 'line-number nil :background "#282a36" 
:foreground "#6272a4")
   (set-face-attribute 'line-number-current-line nil :background 
"#282a36" :foreground "#f8f8f2")
- Increasing display-line-numbers-width does not affect the artifacts.

Expected behavior:
Line-number margin should update cleanly without leaving visual artifacts.

This appears to be related specifically to the redraw path of relative 
line numbers in `display-line-numbers-mode`.

additional useful info:

In GNU Emacs 30.2 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.41,
  cairo version 1.18.0) of 2025-08-15 built on lcy02-amd64-116
Repository revision: 32909ac267415e06a8b18a8b89827d7bbf180b58
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12302006
System Description: Ubuntu 24.04.3 LTS

Configured using:
  'configure --prefix=/snap/emacs/current/usr --with-x-toolkit=gtk3
  --without-xaw3d --with-modules --with-cairo
  --with-native-compilation=aot --without-pgtk --with-xinput2
  --with-tree-sitter 'CFLAGS=-isystem
  /build/emacs/parts/emacs/install/usr/include -isystem
  /build/emacs/parts/emacs/install/usr/include/x86_64-linux-gnu -isystem
  /build/emacs/stage/usr/include -O2' 'CPPFLAGS=-isystem
  /build/emacs/parts/emacs/install/usr/include -isystem
  /build/emacs/parts/emacs/install/usr/include/x86_64-linux-gnu -isystem
  /build/emacs/stage/usr/include'
  'LDFLAGS=-L/build/emacs/parts/emacs/install/lib
  -L/build/emacs/parts/emacs/install/usr/lib
  -L/build/emacs/parts/emacs/install/lib/x86_64-linux-gnu
  -L/build/emacs/parts/emacs/install/usr/lib/x86_64-linux-gnu
  -L/build/emacs/stage/usr/lib''

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

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

Major mode: ELisp/d

Minor modes in effect:
   global-company-mode: t
   company-mode: t
   global-display-line-numbers-mode: t
   display-line-numbers-mode: t
   override-global-mode: t
   tooltip-mode: t
   global-eldoc-mode: t
   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 yank-media puny dired
dired-loaddefs rfc822 mml mml-sec epa epg rfc6068 epg-config gnus-util
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr
mail-utils time-date company-oddmuse company-keywords company-etags
etags fileloop generator xref project company-gtags company-dabbrev-code
company-dabbrev company-files company-clang company-capf company-cmake
company-semantic company-template company-bbdb company pcase sclang
sclang-widgets tree-widget wid-edit sclang-server sclang-help
sclang-help-minor-mode sclang-minor-mode sclang-mode derived sclang-dev
sclang-document sclang-language sclang-interp compile
text-property-search comint ansi-osc ansi-color ring sclang-browser view
sclang-util dracula-theme display-line-numbers use-package
use-package-ensure use-package-delight use-package-diminish
use-package-bind-key bind-key easy-mmode use-package-core finder-inf
site-start comp comp-cstr cl-extra help-mode comp-common warnings rx
company-autoloads dracula-theme-autoloads ement-autoloads
lua-mode-autoloads persist-autoloads plz-autoloads svg-lib-autoloads
taxy-magit-section-autoloads taxy-autoloads info magit-section-autoloads
llama-autoloads package browse-url url url-proxy url-privacy url-expand
url-methods url-history url-cookie generate-lisp-file url-domsuf
url-util mailcap url-handlers url-parse auth-source cl-seq eieio
eieio-core cl-macs icons password-cache json subr-x map byte-opt gv
bytecomp byte-compile url-vars cl-loaddefs cl-lib rmc iso-transl tooltip
cconv eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type
elisp-mode mwheel term/x-win x-win term/common-win x-dnd touch-screen
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 dbusbind
inotify lcms2 dynamic-setting system-font-setting font-render-setting
cairo gtk x-toolkit xinput2 x multi-tty move-toolbar
make-network-process native-compile emacs)

Memory information:
((conses 16 204139 13238) (symbols 48 14132 0) (strings 32 48749 4819)
  (string-bytes 1 1433272) (vectors 16 24295)
  (vector-slots 8 289139 15606) (floats 8 93 160)
  (intervals 56 993 357) (buffers 992 16))