Subject: Re: bug#32072: 27.0.50; clear-face-cache in an X frame breaks tty colors

From: Eli Zaretskii <[email-masked]>
Date: Sat, 07 Jul 2018 11:14:39 +0300

> From: Istvan Marko <[email-masked]>
> Date: Fri, 06 Jul 2018 10:18:39 -0700
> 
> When an Emacs session has both an X11 frame and a tty frame on a 256
> color capable terminal calling (clear-face-cache) in the X11 frame
> results in the colors getting messed up in the existing tty frame.

Can you tell more about what "messed-up" means?  E.g., what do you see
if you type "M-x list-colors-display RET" in a TTY frame after
invoking clear-face-cache on a GUI frame?

> Newly created tty frames are OK. Running (clear-face-cache) in the
> tty frame fixes the affected frame.

Strange: clear-face-cache does not work only on the selected frame, it
clears the face caches of _all_ the GUI frames, and is supposed to do
nothing for TTY frames, except forcing recreation of all faces on the
next redisplay.  So I'm not sure I understand what does "Running
(clear-face-cache) in the tty frame" mean.  Are you saying that if all
frames in a session are TTY frames, the problem doesn't happen?  Or do
you mean that a _second_ call to clear-face-cache fixes the TTY
frames?  If the latter, does it matter what frame is selected when you
issue that second call?

What if you invoke clear-face-cache, and then type "M-x redraw-display
RET" in a TTY frame -- does that still show "messed-up" colors?

> Start Emacs in X11 mode and start Emacs server:
> 
> emacs -Q
> M-x server-start
> 
> Then in a 256 color terminal with TERM=xterm-256color or similar:
> 
> emacsclient -t
> 
> Then switch back to the X frame and evaluate:
> 
> M-: (clear-face-cache) RET
> 
> This immediately corrupts the colors of the tty frame. Not sure if all
> faces are affected but the mode-line face for example always turns black
> or green for me so it's very obvious.

"Black or green"?  So the effect is not entirely deterministic?

Do you see this in Emacs 26 as well, or only on the master branch?

Thanks.