all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#71866: 30.0.50; [macOS] Cursor hiding char behind it with certain theme customization
@ 2024-07-01  3:14 Dmitry Gutov
  2024-07-01 11:36 ` Eli Zaretskii
  2024-07-02 23:42 ` Stefan Kangas
  0 siblings, 2 replies; 6+ messages in thread
From: Dmitry Gutov @ 2024-07-01  3:14 UTC (permalink / raw)
  To: 71866

[-- Attachment #1: Type: text/plain, Size: 1362 bytes --]

Repro script is attached. Disabling blink-cursor-mode is not a
hard requirement, but it makes the bug easier to see. The font and face
customizations are both necessary.

1. emacs -Q -l nocursor-repro.el
2. Type 'asdasd' (without quotes)
3. Move point to either of the 's' chars
4. Create a new frame with 'C-x 5 2'

The character under cursor won't be visible - just a blank cell (the
cursor is blank as well). Then I move point with e.g. C-f and it's
visible again.

Switching between the frames (C-x 5 o) will make the char again 
invisible, as long as the point is on an 's' (in this specific scenario, 
that is). And only in the second frame (or others created later) but not 
the first one.

This only happens on my macOS machine.

The face customization is a part of a 3rd party theme (tango-plus).  I'm
pretty sure the :inverse-video customization should be a no-op but it
isn't. Seems like a subtle bug somewhere. As a user of the theme it's
taken me a while to narrow down the problem, so it'd be great if someone
could look into it.

In GNU Emacs 30.0.50 (build 3, aarch64-apple-darwin23.3.0, NS
appkit-2487.40 Version 14.3 (Build 23D56)) of 2024-06-04 built on
dizzy.local
Repository revision: 43c354a0004145c04bbc6adf0cfaa8c21403ad8c
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2487
System Description:  macOS 14.3


[-- Attachment #2: nocursor-repro.el --]
[-- Type: application/octet-stream, Size: 393 bytes --]

;; This buffer is for text that is not saved, and for Lisp evaluation.
;; To create a file, visit it with ‘C-x C-f’ and enter text in its buffer.

(set-face-attribute 'default nil :family "Cascadia Mono")

(blink-cursor-mode -1)

(custom-theme-set-faces
 'user
 '(cursor                         ((((class color) (min-colors 89))
                                    (:inverse-video t)))))


^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#71866: 30.0.50; [macOS] Cursor hiding char behind it with certain theme customization
  2024-07-01  3:14 bug#71866: 30.0.50; [macOS] Cursor hiding char behind it with certain theme customization Dmitry Gutov
@ 2024-07-01 11:36 ` Eli Zaretskii
  2024-07-02  1:07   ` Dmitry Gutov
  2024-07-02 23:42 ` Stefan Kangas
  1 sibling, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2024-07-01 11:36 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 71866

> Date: Mon, 1 Jul 2024 06:14:28 +0300
> From: Dmitry Gutov <dmitry@gutov.dev>
> 
> Repro script is attached. Disabling blink-cursor-mode is not a
> hard requirement, but it makes the bug easier to see. The font and face
> customizations are both necessary.
> 
> 1. emacs -Q -l nocursor-repro.el
> 2. Type 'asdasd' (without quotes)
> 3. Move point to either of the 's' chars
> 4. Create a new frame with 'C-x 5 2'
> 
> The character under cursor won't be visible - just a blank cell (the
> cursor is blank as well). Then I move point with e.g. C-f and it's
> visible again.

This is definitely macOS specific.  I cannot reproduce on my system
(although by some miracle I do have the Cascadia Mono font installed).
Basically, what happens is that redisplay has some bug in how it draws
the cursor.  Given all the tricks that redisplay plays on macOS, I'm
not surprised.

On other platforms, the code which draws the cursor is in draw_glyphs,
called from XXX_draw_window_cursor function (where XXX is the GUI
backend, in your case probably XXX = ns).  If the same is true on
macOS, you could try stepping through that code.

> The face customization is a part of a 3rd party theme (tango-plus).  I'm
> pretty sure the :inverse-video customization should be a no-op but it
> isn't. Seems like a subtle bug somewhere. As a user of the theme it's
> taken me a while to narrow down the problem, so it'd be great if someone
> could look into it.

So if inverse-video is not used, the problem goes away?  If so, just
don't use it.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#71866: 30.0.50; [macOS] Cursor hiding char behind it with certain theme customization
  2024-07-01 11:36 ` Eli Zaretskii
@ 2024-07-02  1:07   ` Dmitry Gutov
  2024-07-06  8:56     ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Gutov @ 2024-07-02  1:07 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: 71866

On 01/07/2024 14:36, Eli Zaretskii wrote:
>> Date: Mon, 1 Jul 2024 06:14:28 +0300
>> From: Dmitry Gutov <dmitry@gutov.dev>
>>
>> Repro script is attached. Disabling blink-cursor-mode is not a
>> hard requirement, but it makes the bug easier to see. The font and face
>> customizations are both necessary.
>>
>> 1. emacs -Q -l nocursor-repro.el
>> 2. Type 'asdasd' (without quotes)
>> 3. Move point to either of the 's' chars
>> 4. Create a new frame with 'C-x 5 2'
>>
>> The character under cursor won't be visible - just a blank cell (the
>> cursor is blank as well). Then I move point with e.g. C-f and it's
>> visible again.
> 
> This is definitely macOS specific.  I cannot reproduce on my system
> (although by some miracle I do have the Cascadia Mono font installed).
> Basically, what happens is that redisplay has some bug in how it draws
> the cursor.  Given all the tricks that redisplay plays on macOS, I'm
> not surprised.

Indeed, it never happens on my Linux system either. Thanks for checking 
anyway.

> On other platforms, the code which draws the cursor is in draw_glyphs,
> called from XXX_draw_window_cursor function (where XXX is the GUI
> backend, in your case probably XXX = ns).  If the same is true on
> macOS, you could try stepping through that code.

I can try following some more detailed instructions. I.e. I can set up a 
breakpoint, but would there be anything to look out for when stepping 
through the code?

BTW, this happens only right after I switch frames. Things start looking 
right again if I simply move point.

>> The face customization is a part of a 3rd party theme (tango-plus).  I'm
>> pretty sure the :inverse-video customization should be a no-op but it
>> isn't. Seems like a subtle bug somewhere. As a user of the theme it's
>> taken me a while to narrow down the problem, so it'd be great if someone
>> could look into it.
> 
> So if inverse-video is not used, the problem goes away?  If so, just
> don't use it.

Yeah, I plan on submitting a patch to that effect to the theme.

But the bug looks odd enough and the same time very stable, that I think 
it's worth investigating.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#71866: 30.0.50; [macOS] Cursor hiding char behind it with certain theme customization
  2024-07-01  3:14 bug#71866: 30.0.50; [macOS] Cursor hiding char behind it with certain theme customization Dmitry Gutov
  2024-07-01 11:36 ` Eli Zaretskii
@ 2024-07-02 23:42 ` Stefan Kangas
  2024-07-07  2:03   ` Dmitry Gutov
  1 sibling, 1 reply; 6+ messages in thread
From: Stefan Kangas @ 2024-07-02 23:42 UTC (permalink / raw)
  To: Dmitry Gutov, 71866

Dmitry Gutov <dmitry@gutov.dev> writes:

> Repro script is attached. Disabling blink-cursor-mode is not a
> hard requirement, but it makes the bug easier to see. The font and face
> customizations are both necessary.
>
> 1. emacs -Q -l nocursor-repro.el
> 2. Type 'asdasd' (without quotes)
> 3. Move point to either of the 's' chars
> 4. Create a new frame with 'C-x 5 2'
>
> The character under cursor won't be visible - just a blank cell (the
> cursor is blank as well). Then I move point with e.g. C-f and it's
> visible again.
>
> Switching between the frames (C-x 5 o) will make the char again
> invisible, as long as the point is on an 's' (in this specific scenario,
> that is). And only in the second frame (or others created later) but not
> the first one.
>
> This only happens on my macOS machine.
>
> The face customization is a part of a 3rd party theme (tango-plus).  I'm
> pretty sure the :inverse-video customization should be a no-op but it
> isn't. Seems like a subtle bug somewhere. As a user of the theme it's
> taken me a while to narrow down the problem, so it'd be great if someone
> could look into it.

I can't reproduce that here, using the above recipe.

Maybe try upgrading to macOS 14.5 to see if the problem goes away?

In GNU Emacs 31.0.50 (build 1, aarch64-apple-darwin23.5.0, NS
 appkit-2487.60 Version 14.5 (Build 23F79)) of 2024-07-01 built on
 foo.local
Repository revision: 4008385b8d48b1a8e670ac497c3b8a12b9605a4e
Repository branch: master
Windowing system distributor 'Apple', version 10.3.2487
System Description:  macOS 14.5

> In GNU Emacs 30.0.50 (build 3, aarch64-apple-darwin23.3.0, NS
> appkit-2487.40 Version 14.3 (Build 23D56)) of 2024-06-04 built on
> dizzy.local
> Repository revision: 43c354a0004145c04bbc6adf0cfaa8c21403ad8c
> Repository branch: master
> Windowing system distributor 'Apple', version 10.3.2487
> System Description:  macOS 14.3





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#71866: 30.0.50; [macOS] Cursor hiding char behind it with certain theme customization
  2024-07-02  1:07   ` Dmitry Gutov
@ 2024-07-06  8:56     ` Eli Zaretskii
  0 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2024-07-06  8:56 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 71866

> Date: Tue, 2 Jul 2024 04:07:11 +0300
> Cc: 71866@debbugs.gnu.org
> From: Dmitry Gutov <dmitry@gutov.dev>
> 
> On 01/07/2024 14:36, Eli Zaretskii wrote:
> > On other platforms, the code which draws the cursor is in draw_glyphs,
> > called from XXX_draw_window_cursor function (where XXX is the GUI
> > backend, in your case probably XXX = ns).  If the same is true on
> > macOS, you could try stepping through that code.
> 
> I can try following some more detailed instructions. I.e. I can set up a 
> breakpoint, but would there be anything to look out for when stepping 
> through the code?

For starters, put a breakpoint in ns_draw_window_cursor and see if it
gets called in the scenario where you see the problem.

If it does get called, it should call draw_phys_cursor_glyph in this
case (because the cursor type is FILLED_BOX_CURSOR).  If it calls that
function, step through it.  You should see there that it calls
draw_glyphs to draw the single character under the cursor.  The actual
drawing happens here:

  /* Draw all strings.  */
  for (s = head; s; s = s->next)
    FRAME_RIF (f)->draw_glyph_string (s);

where the draw_glyph_string method is a function in nsterm.m,
ns_draw_glyph_string.  AFAICT, it should draw a character with the
foreground taken from the frame's background color and background
color taken from the cursor color.

Something in this chain of calls doesn't happen in the scenario which
shows the problem.

> BTW, this happens only right after I switch frames. Things start looking 
> right again if I simply move point.

Then step through the code after switching frames.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#71866: 30.0.50; [macOS] Cursor hiding char behind it with certain theme customization
  2024-07-02 23:42 ` Stefan Kangas
@ 2024-07-07  2:03   ` Dmitry Gutov
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Gutov @ 2024-07-07  2:03 UTC (permalink / raw)
  To: Stefan Kangas, 71866

On 03/07/2024 02:42, Stefan Kangas wrote:

> I can't reproduce that here, using the above recipe.

Thanks for trying anyway.

> Maybe try upgrading to macOS 14.5 to see if the problem goes away?

Upgraded to 14.5 now (apparently the upgrades were being blocked by a 
vpn being always on) - but the problem remains the same.

Not sure what is the difference between our machines - but mine is an M3 
Pro, FWIW.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-07-07  2:03 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-01  3:14 bug#71866: 30.0.50; [macOS] Cursor hiding char behind it with certain theme customization Dmitry Gutov
2024-07-01 11:36 ` Eli Zaretskii
2024-07-02  1:07   ` Dmitry Gutov
2024-07-06  8:56     ` Eli Zaretskii
2024-07-02 23:42 ` Stefan Kangas
2024-07-07  2:03   ` Dmitry Gutov

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.