all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dmitry@gutov.dev>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 71866@debbugs.gnu.org
Subject: bug#71866: 30.0.50; [macOS] Cursor hiding char behind it with certain theme customization
Date: Sun, 21 Jul 2024 03:53:26 +0300	[thread overview]
Message-ID: <ad0b5c70-49ac-4c5a-840b-fe25cf3ffe64@gutov.dev> (raw)
In-Reply-To: <86o76scaou.fsf@gnu.org>

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

On 20/07/2024 19:03, Eli Zaretskii wrote:
>> Date: Sat, 20 Jul 2024 18:46:50 +0300
>> Cc: 71866@debbugs.gnu.org
>> From: Dmitry Gutov <dmitry@gutov.dev>
>>
>>> I don't really see any useful information here, except that the last
>>> call tells Emacs to show the cursor using type NO_CURSOR (i.e. not to
>>> display anything).
>>
>> I do see a bunch of such calls earlier as well, but they don't seem to
>> result in no cursor being displayed - just in it not being updated, maybe?
> 
> It depends on what was redrawn before that.

Perhaps it'll be easier to share a video. Sorry, it's a large file, so I 
just uploaded it to a free online hosting: https://streamable.com/d6775w

The first (smaller) part is me reproducing the bug, then I switch to the 
terminal emulator, enable the breakpoint and demonstrate how the 
behavior of the same command (other-frame) changes.

After the video was finished, I also repeated the same scenario, and 
saved the backtrace of the last (12th) breakpoint hit.

>>> I don't understand why this happens; the value is
>>> returned by get_window_cursor_type called inside
>>> display_and_set_cursor (which is what gui_update_window_end calls on
>>> line 3941 of dispnew.c, but the backtrace doesn't even mention that).
>>>
>>> But before we try to analyze this situation, shouldn't we try to stick
>>> to the original issue?  Why could not you investigate what happens in
>>> that case?
>>
>> The scenario that I'm trying is the same that creates the original problem.
> 
> That's not what you said, or maybe I misunderstood.
> 
> But anyway, if this is the same scenario, then why are you only
> looking at what happens inside ns_draw_window_cursor?  Redrawing the
> block cursor involves displaying the character under cursor with
> special colors, and ns_draw_window_cursor is just the beginning: it
> calls other functions which actually do the job.

More breakpoints means more chances for the behavior to change. I also 
don't really know which other places to look at. Stepping through all 
the callees is both time-consuming and something that is unlikely to 
help until I manage to read all of the underlying implementation and 
start making sense of the data that's being used, to be able to notice 
when this or that variable has an odd value.

But maybe at this point some print-debugging might be more beneficial 
(since that shouldn't change the existing behavior). See the linked 
video and the attached backtrace, though.

> In addition, I don't think I understand from the debug session which
> call to ns_draw_window_cursor was done in what situation.  If they all
> were part of the single repetition of the scenario, then without fully
> functional backtraces it is very hard to understand anything that goes
> on here.  Using an unoptimized build might help, which is why I
> suggested that (unless the problem disappears in an unoptimized
> build).

Yes, I've reconfigured and rebuilt with CFLAGS="-O0 -g3". That fixed the 
backtrace printing, at least.

[-- Attachment #2: emacs-lldb-bt-2.txt --]
[-- Type: text/plain, Size: 5407 bytes --]

* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
    frame #0: 0x0000000100354f44 emacs`ns_draw_window_cursor(w=0x00000001280208f8, glyph_row=0x00000001280bc800, x=0, y=0, cursor_type=NO_CURSOR, cursor_width=0, on_p=true, active_p=false) at nsterm.m:3045:25
   3042	  if (!on_p)
   3043	    return;
   3044
-> 3045	  w->phys_cursor_type = cursor_type;
   3046	  w->phys_cursor_on_p = on_p;
   3047
   3048	  if (cursor_type == NO_CURSOR)
Target 0: (emacs) stopped.
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
  * frame #0: 0x0000000100354f44 emacs`ns_draw_window_cursor(w=0x00000001280208f8, glyph_row=0x00000001280bc800, x=0, y=0, cursor_type=NO_CURSOR, cursor_width=0, on_p=true, active_p=false) at nsterm.m:3045:25
    frame #1: 0x000000010007035c emacs`display_and_set_cursor(w=0x00000001280208f8, on=true, hpos=0, vpos=0, x=0, y=0) at xdisp.c:34205:5
    frame #2: 0x0000000100070d24 emacs`update_window_cursor(w=0x00000001280208f8, on=true) at xdisp.c:34240:7
    frame #3: 0x0000000100070b1c emacs`update_cursor_in_window_tree(w=0x00000001280208f8, on_p=true) at xdisp.c:34258:2
    frame #4: 0x0000000100070aa0 emacs`gui_update_cursor(f=0x0000000128020400, on_p=true) at xdisp.c:34272:3
    frame #5: 0x0000000100344770 emacs`-[EmacsView windowDidResignKey:](self=0x000000011e912750, _cmd="windowDidResignKey:", notification=@"NSWindowDidResignKeyNotification") at nsterm.m:7960:7
    frame #6: 0x0000000184db3144 CoreFoundation`__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 148
    frame #7: 0x0000000184e473d8 CoreFoundation`___CFXRegistrationPost_block_invoke + 88
    frame #8: 0x0000000184e47320 CoreFoundation`_CFXRegistrationPost + 440
    frame #9: 0x0000000184d81678 CoreFoundation`_CFXNotificationPost + 768
    frame #10: 0x0000000185e9e4e4 Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 88
    frame #11: 0x00000001887776fc AppKit`-[NSWindow resignKeyWindow] + 640
    frame #12: 0x00000001887773e4 AppKit`_NXEndKeyAndMain + 128
    frame #13: 0x00000001887764ec AppKit`-[NSApplication _handleDeactivateEvent:] + 724
    frame #14: 0x0000000188e106b8 AppKit`-[NSApplication(NSEventRouting) sendEvent:] + 1236
    frame #15: 0x000000010033bcd8 emacs`-[EmacsApp sendEvent:](self=0x000000012f01ee10, _cmd="sendEvent:", theEvent=0x0000600003cf5800) at nsterm.m:6073:3
    frame #16: 0x0000000188a5e89c AppKit`-[NSApplication _handleEvent:] + 60
    frame #17: 0x000000018860f0c0 AppKit`-[NSApplication run] + 512
    frame #18: 0x000000010033b838 emacs`-[EmacsApp run](self=0x000000012f01ee10, _cmd="run") at nsterm.m:5942:7
    frame #19: 0x00000001003560b0 emacs`ns_read_socket_1(terminal=0x000000012f858610, hold_quit=0x000000016fdfaf70, no_release=NO) at nsterm.m:4816:11
    frame #20: 0x000000010034fa18 emacs`ns_read_socket(terminal=0x000000012f858610, hold_quit=0x000000016fdfaf70) at nsterm.m:4834:10
    frame #21: 0x000000010016a6dc emacs`gobble_input at keyboard.c:7919:17
    frame #22: 0x000000010016ae10 emacs`handle_async_input at keyboard.c:8158:19
    frame #23: 0x000000010016adf0 emacs`process_pending_signals at keyboard.c:8172:3
    frame #24: 0x000000010016ae9c emacs`unblock_input_to(level=0) at keyboard.c:8187:2
    frame #25: 0x00000001001683a8 emacs`unblock_input at keyboard.c:8206:3
    frame #26: 0x0000000100007504 emacs`gui_update_window_end(w=0x00000001280208f8, cursor_on_p=true, mouse_face_overwritten_p=false) at dispnew.c:3955:7
    frame #27: 0x000000010000603c emacs`update_window(w=0x00000001280208f8, force_p=true) at dispnew.c:3869:7
    frame #28: 0x00000001000061c0 emacs`update_window_tree(w=0x00000001280208f8, force_p=true) at dispnew.c:3491:14
    frame #29: 0x00000001000053a0 emacs`update_frame(f=0x0000000128020400, force_p=true, inhibit_hairy_id_p=false) at dispnew.c:3326:18
    frame #30: 0x000000010004f424 emacs`redisplay_internal at xdisp.c:17480:16
    frame #31: 0x0000000100055ef8 emacs`redisplay at xdisp.c:16575:3
    frame #32: 0x0000000100161e74 emacs`read_char(commandflag=1, map=0x00000001300cbb03, prev_event=0x0000000000000000, used_mouse_menu=0x000000016fdfe807, end_time=0x0000000000000000) at keyboard.c:2678:6
    frame #33: 0x000000010015ea30 emacs`read_key_sequence(keybuf=0x000000016fdfebe8, prompt=0x0000000000000000, dont_downcase_last=false, can_return_switch_frame=true, fix_current_buffer=true, prevent_redisplay=false, disable_text_conversion_p=false) at keyboard.c:10743:12
    frame #34: 0x000000010015cdf8 emacs`command_loop_1 at keyboard.c:1429:15
    frame #35: 0x000000010024923c emacs`internal_condition_case(bfun=(emacs`command_loop_1 at keyboard.c:1324), handlers=0x0000000000000090, hfun=(emacs`cmd_error at keyboard.c:970)) at eval.c:1613:25
    frame #36: 0x000000010015c8c4 emacs`command_loop_2(handlers=0x0000000000000090) at keyboard.c:1168:11
    frame #37: 0x00000001002484d4 emacs`internal_catch(tag=0x0000000000011220, func=(emacs`command_loop_2 at keyboard.c:1164), arg=0x0000000000000090) at eval.c:1292:25
    frame #38: 0x000000010015bc10 emacs`command_loop at keyboard.c:1146:2
    frame #39: 0x000000010015b9fc emacs`recursive_edit_1 at keyboard.c:754:9
    frame #40: 0x000000010015bee8 emacs`Frecursive_edit at keyboard.c:837:3
    frame #41: 0x0000000100158ac8 emacs`main(argc=4, argv=0x000000016fdff4b0) at emacs.c:2624:3
    frame #42: 0x00000001849560e0 dyld`start + 2360

  reply	other threads:[~2024-07-21  0:53 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-09  2:37       ` Dmitry Gutov
2024-07-09 11:31         ` Eli Zaretskii
2024-07-10  2:46           ` Dmitry Gutov
2024-07-10 11:58             ` Eli Zaretskii
2024-07-19  1:57               ` Dmitry Gutov
2024-07-20  8:30                 ` Eli Zaretskii
2024-07-20 15:46                   ` Dmitry Gutov
2024-07-20 16:03                     ` Eli Zaretskii
2024-07-21  0:53                       ` Dmitry Gutov [this message]
2024-07-21  7:20                         ` Eli Zaretskii
2024-07-21  9:04                           ` Eli Zaretskii
2024-07-21 23:22                             ` Dmitry Gutov
2024-07-21 13:50                           ` Dmitry Gutov
2024-07-21 14:55                             ` Eli Zaretskii
2024-07-21 23:58                               ` Dmitry Gutov
2024-07-22 14:45                                 ` Eli Zaretskii
2024-07-22 15:27                                   ` Alan Third
2024-07-22 16:02                                     ` Alan Third
2024-07-23  1:11                                       ` Dmitry Gutov
2024-07-23 11:19                                         ` Eli Zaretskii
2024-07-24  0:48                                           ` Dmitry Gutov
2024-07-24 11:32                                             ` Eli Zaretskii
2024-07-24 14:34                                               ` Dmitry Gutov
2024-07-24 16:29                                                 ` Eli Zaretskii
2024-07-24 19:22                                                   ` Dmitry Gutov
2024-07-24 20:08                                                     ` Dmitry Gutov
2024-07-25  5:01                                                     ` Eli Zaretskii
2024-07-25 16:14                                                       ` Dmitry Gutov
2024-07-22 16:10                                     ` Eli Zaretskii
2024-07-22 19:02                                       ` Alan Third
2024-07-22 19:15                                         ` Eli Zaretskii
2024-07-22 19:47                                           ` Alan Third
2024-07-23  1:06                                   ` Dmitry Gutov
2024-07-23 11:17                                     ` Eli Zaretskii
2024-07-02 23:42 ` Stefan Kangas
2024-07-07  2:03   ` Dmitry Gutov
2024-07-09 18:22     ` Stefan Kangas
2024-07-10  2:56       ` Dmitry Gutov
2024-07-23  7:40         ` Gerd Möllmann
2024-07-24  0:56           ` Dmitry Gutov
2024-07-24  3:48             ` Gerd Möllmann
2024-07-24 19:16               ` Dmitry Gutov
2024-07-25  3:03                 ` Gerd Möllmann
2024-07-25  5:39                   ` Eli Zaretskii
2024-07-25  5:58                     ` Gerd Möllmann
2024-07-25 14:46                   ` Dmitry Gutov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ad0b5c70-49ac-4c5a-840b-fe25cf3ffe64@gutov.dev \
    --to=dmitry@gutov.dev \
    --cc=71866@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.