Subject: 29.0.60; customize checkbox and radio widgets don't render on macOS

From: David Caldwell <[email-masked]>
Date: Sat, 4 Mar 2023 17:35:16 -0800

To reproduce:

   M-x customize-face RET bold RET

It can be any face, that's just an example. In the customize buffer
click or select the "Show All Attributes" button/link at the bottom. The
attributes should have checkboxes in checked or unchecked states but
none show up. Here's a screenshot (the cyan square is my cursor over
where a checkbox should be rendered):

https://porkrind.org/tmp/emacs29-customize-bug-macos.png

This happens in radio buttons too, but I don't know which
customize setting use those.

This also happens in Emacs 28. I have not tried the master branch yet.

I tried to track this down and found that even inserting the checkbox
image fails, though I can insert other SVGs:

Fails:

   (insert-image (find-image '((:file "checked.svg"))))

Works:

   (insert-image (find-image '((:file "splash.svg"))))

It appears to be because the checkbox and radio svgs in etc/images all
use height="1em" and the mac native renderer doesn't like that.

It works with rsvg because the emacs code that interfaces with rsvg code
passes some extra styling info to it so that it can render that properly
(image.c:11226 in the emacs-29 branch for me today).

Unfortunately the native renderer in nsimage.m doesn't do this. I spent
some time today trying to figure it out, but it appears that the cocoa
apis just don't have this feature, so it would have to be done some
other way.

I can confirm this is the issue by opening "etc/images/checked.svg",
hitting "C-c C-c" to edit, changing the "1em" to "16" and "C-c C-c"ing
again to re-render it. It will appear with a non-percentage height.

I really wanted to suggest a fix or a patch, but I'm stuck because I
don't want to flat out turn off svgs on macOS, but I also don't want to
get rid of the nice scaling that librsvg supports. Maybe nsimage.m
should load the svg into memory, check for width or height being "1em"
and manually changing it to something concrete before passing it to the
OS?  Yuck, but also it would probably work.

-David

In GNU Emacs 29.0.60 (build 1, aarch64-apple-darwin22.1.0, NS
  appkit-2299.00 Version 13.0.1 (Build 22A400)) of 2023-03-04 built on
  black.local
Repository revision: bd5115e13479b1d81d6aa09efe362ad14d53c3c6
Repository branch: emacs-29
Windowing system distributor 'Apple', version 10.3.2299
System Description:  macOS 13.0.1

Configured features:
ACL DBUS GIF GMP GNUTLS JPEG LCMS2 LIBXML2 MODULES NOTIFY KQUEUE NS
PDUMPER PNG 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: Custom

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
   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 time-date subr-x crm
thingatpt cus-edit pp cus-start cus-load icons wid-edit cl-loaddefs
cl-lib rmc iso-transl tooltip cconv eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/ns-win ns-win
ucs-normalize mule-util 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 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 kqueue cocoa ns
lcms2 multi-tty make-network-process emacs)

Memory information:
((conses 16 68647 5810)
  (symbols 48 7188 0)
  (strings 32 18140 1297)
  (string-bytes 1 468742)
  (vectors 16 11324)
  (vector-slots 8 174536 16175)
  (floats 8 38 31)
  (intervals 56 1508 3)
  (buffers 984 13))