Subject: bug#42406: Mouse-wheel scrolling can be flickering

From: Konrad Podczeck <[email-masked]>
Date: Mon, 14 Dec 2020 01:20:39 +0100

In view of the comments made by Eli, I made a shoot in the dark, and, in window.c, commented out the occurrences of wset_update_mode_line on lines 1850, 4011, 5630, 5819, 6079, as well as the respective line after the three statements lines where "Bug#15957" is written. With these (actually I have not testes which of these (out-commentings are relevant) the problem has completely gone. I am aware that this is not a real solution, but it shows that there is some room. Which are the risks caused by these changes of the code?

> Am 13.12.2020 um 20:46 schrieb Alan Third <[email-masked]>:
> 
> On Sun, Dec 13, 2020 at 09:05:29PM +0200, Eli Zaretskii wrote:
>>> Date: Fri, 11 Dec 2020 20:37:56 +0000
>>> From: Alan Third <[email-masked]>
>>> Cc: [email-masked], [email-masked]
>>> 
>>>> Any pointers to the code which causes all the frames to be updated in
>>>> C-v/M-v case?
>>> 
>>> I don't know. I'm looking at redisplay_internal in a debugger and I
>>> can see that consider_all_windows_p is true, which will be because
>>> windows_or_buffers_changed == 2 == REDISPLAY_SOME or because
>>> update_mode_lines == 42.
>>> 
>>> I can't find anywhere that sets update_mode_lines to 42...
>> 
>> wset_update_mode_line does it, so any caller of that function would.
>> 
>> But where do you see the value of 42 being tested?
> 
> I've got two frames open, I set up a breakpoint in
> ns_clear_under_internal_border and scroll. When I hit the breakpoint
> for the frame I don't expect to be updated I get this backtrace:
> 
> * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
>  * frame #0: 0x00000001001eb35f temacs`ns_clear_under_internal_border(f=0x000000010711cea0) at nsterm.m:3036:7 [opt]
>    frame #1: 0x0000000100029cd5 temacs`redisplay_internal at xdisp.c:16030:21 [opt]
>    frame #2: 0x00000001000cb1d5 temacs`read_char(commandflag=1, map=0x0000000107d635c3, prev_event=0x0000000000000000, used_mouse_menu=0x00007ffeefbff36b, end_time=0x0000000000000000) at keyboard.c:2496:6 [opt]
>    frame #3: 0x00000001000c8e72 temacs`read_key_sequence(keybuf=<unavailable>, prompt=0x0000000000000000, dont_downcase_last=<unavailable>, can_return_switch_frame=<unavailable>, fix_current_buffer=<unavailable>, prevent_redisplay=<unavailable>) at keyboard.c:9483:12 [opt]
>    frame #4: 0x00000001000c756c temacs`command_loop_1 at keyboard.c:1353:15 [opt]
>    frame #5: 0x000000010014dd17 temacs`internal_condition_case(bfun=(temacs`command_loop_1 at keyboard.c:1239), handlers=0x0000000000000090, hfun=(temacs`cmd_error at keyboard.c:922)) at eval.c:1415:25 [opt]
>    frame #6: 0x00000001000d7670 temacs`command_loop_2(ignore=<unavailable>) at keyboard.c:1094:11 [opt]
>    frame #7: 0x000000010014d53b temacs`internal_catch(tag=0x000000000000c9f0, func=(temacs`command_loop_2 at keyboard.c:1090), arg=0x0000000000000000) at eval.c:1176:25 [opt]
>    frame #8: 0x0000000100212935 temacs`command_loop.cold.1 + 69
>    frame #9: 0x00000001000c6633 temacs`command_loop at keyboard.c:1072:2 [opt]
>    frame #10: 0x00000001000c6563 temacs`recursive_edit_1 at keyboard.c:720:9 [opt]
>    frame #11: 0x00000001000c67bb temacs`Frecursive_edit at keyboard.c:789:3 [opt]
>    frame #12: 0x00000001000c5343 temacs`main(argc=<unavailable>, argv=0x00007ffeefbff810) at emacs.c:2054:3 [opt]
>    frame #13: 0x00007fff712cd3d5 libdyld.dylib`start + 1* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
>  * frame #0: 0x00000001001eb35f temacs`ns_clear_under_internal_border(f=0x000000010711cea0) at nsterm.m:3036:7 [opt]
>    frame #1: 0x0000000100029cd5 temacs`redisplay_internal at xdisp.c:16030:21 [opt]
>    frame #2: 0x00000001000cb1d5 temacs`read_char(commandflag=1, map=0x0000000107d635c3, prev_event=0x0000000000000000, used_mouse_menu=0x00007ffeefbff36b, end_time=0x0000000000000000) at keyboard.c:2496:6 [opt]
>    frame #3: 0x00000001000c8e72 temacs`read_key_sequence(keybuf=<unavailable>, prompt=0x0000000000000000, dont_downcase_last=<unavailable>, can_return_switch_frame=<unavailable>, fix_current_buffer=<unavailable>, prevent_redisplay=<unavailable>) at keyboard.c:9483:12 [opt]
>    frame #4: 0x00000001000c756c temacs`command_loop_1 at keyboard.c:1353:15 [opt]
>    frame #5: 0x000000010014dd17 temacs`internal_condition_case(bfun=(temacs`command_loop_1 at keyboard.c:1239), handlers=0x0000000000000090, hfun=(temacs`cmd_error at keyboard.c:922)) at eval.c:1415:25 [opt]
>    frame #6: 0x00000001000d7670 temacs`command_loop_2(ignore=<unavailable>) at keyboard.c:1094:11 [opt]
>    frame #7: 0x000000010014d53b temacs`internal_catch(tag=0x000000000000c9f0, func=(temacs`command_loop_2 at keyboard.c:1090), arg=0x0000000000000000) at eval.c:1176:25 [opt]
>    frame #8: 0x0000000100212935 temacs`command_loop.cold.1 + 69
>    frame #9: 0x00000001000c6633 temacs`command_loop at keyboard.c:1072:2 [opt]
>    frame #10: 0x00000001000c6563 temacs`recursive_edit_1 at keyboard.c:720:9 [opt]
>    frame #11: 0x00000001000c67bb temacs`Frecursive_edit at keyboard.c:789:3 [opt]
>    frame #12: 0x00000001000c5343 temacs`main(argc=<unavailable>, argv=0x00007ffeefbff810) at emacs.c:2054:3 [opt]
>    frame #13: 0x00007fff712cd3d5 libdyld.dylib`start + 1
> 
> Which I've not found very useful. I had a look at redisplay_internal
> to see if I could work out why the frame is being updated, but I
> can't.
> 
> I looked at some of the variables in redisplay_internal that are
> involved in making the decision whether to check all frames:
> 
> (lldb) p update_mode_lines;
> (int) $0 = 42
> (lldb) p windows_or_buffers_changed
> (int) $1 = 2
> 
> but I have no idea if this is useful at all.
> 
> Is there anything specific you'd like me to check?
> -- 
> Alan Third