Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Showing in alt-screen and switching back and to alt-screen again incorrectly removes image leaving black area instead #2901

Closed
aslpavel opened this issue Aug 6, 2020 · 0 comments
Labels

Comments

@aslpavel
Copy link
Contributor

aslpavel commented Aug 6, 2020

Describe the bug
If you show an image in alt screen mode then switch back, and to alt screen mode again. Instead of the clean screen you will see a black area where image used to be. This area not following scroll and is pinned to the screen. I think underlying data is freed but kitty tries to access it and show for whatever reason.

To Reproduce
Steps to reproduce the behavior:

# alt scrreen
printf "\x1b[?1049h"
# position
printf "\x1b[1;1H"
# show image
printf "\x1b_Ga=T,f=32,o=z,v=32,s=26,m=0;eJztldlPU0EUxv80E5c39dUYEyPRxGjUCBHDFhYRgoqUSgmtbaEtpaEtW6FlKUVogVaxbCpQUFJQlLIIqEQFHj7vN+Q2TaEsJsaXPpzcM2e+85uZOzNnFCdSoUha0v6jlZ9Ogy4lB9asYjgelcKlUKCr8hk82kr0GdTC6DPGPmqo1aVko/xU2oHsYJsJK7Pd+LHoxfaGHzvfAn9lzCWDLDJjx7CkFwpNZLoT0wN2jHWY4bfq4XleCefTMrQUP0FDfgnqM4pgTi0QRp8x9lFDLXOYSwZZZJItj+M1afbEdFey4SgpFX0vG6ox7DRhvKtOfNlmnP3U7fd/5LlTJ8cmXtTj1+oAyk+mwXQnH8sf3AgPOzDeWQdvrQbuqgox5+ai3bmz7ZPiHJc66pmnlPZ1xFWL3poqwSKTbHmcT2+cWJG09F811Qid4kTqkY165tnzSgRrbc4j4mSyLeu+hj1iXvTnRhww3MgVvjn1AdxqFfrrtAi2GtH08PG+4xhu5om82PUwTibZsm5zyYcpr034kVBnNP5lsh0Bmx490hl2lSmgvZyVcE2xebKRSbbc/r02iHG3RfhLM13R+MJbV0JuvMXmyUYm2XJ7eyOA0Xaz8BenOqJx7nUibrwxT30hA16jevcsSneXTLJlzRbXI52dRPM6ijEvfhwyt2LW83O5HxO9VuHv95+PYszjWTbeyofpdj40lzIFk2xZs/6xB7NDzcKfH2uD/mrOscbQX8vB/Ggraq7nYsbfiPeBRqk26ASTbFnHc7UY2t2XoMMoztdxxqH+tZQXHyeTbLkdkurRZsQrfMv9QqxKNXDKZ0PAXo2OCiWapRpmzZJq290C8WWbcfZTRz3rTDjYIrjhoEOwNiM+hPrt0XECdr2oRVw326pz6ajPLEK3RoWhFoPYz8k+K2YGG8SXbcbZT53qbPqetZBFJu+fHOM9Z2xSule91VWihjFfK9VI5ZmD3xMaNdQyh7lkkEVmbA2hbuGdK+GbsrXuFzWRd/v75z5h9BljX6I83nPWovh5qS9mwHKvEK3S2ed7OeysFed/55C3jRpqmcNcMsg67D/Emup8Omw5xWhXlu95txljHzXHYSYtaf/a/gBJvFpP\x1b\\"
# wait for image
sleep 1
# diable alt screen
printf "\x1b[?1049l"
# eanble alt screen again
printf "\x1b[?1049h"

Expected behavior
According to the spec:
When switching from the main screen to the alternate screen buffer (1049 private mode) all images in the alternate screen must be cleared, just as all text is cleared.

Screenshots
Screenshot 2020-08-06 at 13 30 39

Environment details
OS: Mac OS 10.15.5

kitty 0.18.2 created by Kovid Goyal
Darwin aslpavel-mbp 19.5.0 Darwin Kernel Version 19.5.0: Tue May 26 20:41:44 PDT 2020; root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64
ProductName:	Mac OS X ProductVersion:	10.15.5 BuildVersion:	19F101
Loaded config files: /Users/aslpavel/.config/kitty/kitty.conf

Config options different from defaults:
active_border_color                Color(red=102, green=92, blue=84)
active_tab_background              Color(red=7, green=102, blue=120)
active_tab_font_style              (True, False)
active_tab_foreground              Color(red=235, green=219, blue=178)
allow_remote_control               y
background                         Color(red=40, green=40, blue=40)
bold_font                          Iosevka Term Bold
bold_italic_font                   Iosevka Term Bold Italic
clipboard_control                  frozenset({'no-append', 'write-primary', 'read-primary', 'write-clipboard'})
close_on_child_death               True
color0                             Color(red=40, green=40, blue=40)
color1                             Color(red=204, green=36, blue=29)
color10                            Color(red=184, green=187, blue=38)
color11                            Color(red=250, green=189, blue=47)
color12                            Color(red=131, green=165, blue=152)
color13                            Color(red=211, green=134, blue=155)
color14                            Color(red=142, green=192, blue=124)
color15                            Color(red=251, green=241, blue=199)
color2                             Color(red=152, green=151, blue=26)
color3                             Color(red=215, green=153, blue=33)
color4                             Color(red=69, green=133, blue=136)
color5                             Color(red=177, green=98, blue=134)
color6                             Color(red=104, green=157, blue=106)
color7                             Color(red=235, green=219, blue=178)
color8                             Color(red=124, green=111, blue=100)
color9                             Color(red=251, green=73, blue=52)
cursor                             Color(red=235, green=219, blue=178)
cursor_blink_interval              0.0
cursor_shape                       2
cursor_text_color                  Color(red=235, green=219, blue=178)
disable_ligatures                  2
enable_audio_bell                  False
font_family                        Iosevka Term
font_size                          13.0
foreground                         Color(red=235, green=219, blue=178)
inactive_border_color              Color(red=80, green=73, blue=69)
inactive_tab_background            Color(red=60, green=56, blue=54)
inactive_tab_foreground            Color(red=213, green=196, blue=161)
italic_font                        Iosevka Term Italic
kitty_mod                          8
macos_option_as_alt                3
macos_quit_when_last_window_closed True
symbol_map                         {(58874, 58923): 'Symbols Nerd Font', (59136, 59333): 'Symbols Nerd Font', (61440, 62176): 'Symbols Nerd Font', (57856, 58025): 'Symbols Nerd Font', (62720, 64838): 'Symbols Nerd Font', (58112, 58347): 'Symbols Nerd Font', (62464, 62632): 'Symbols Nerd Font', (9829, 9829): 'Symbols Nerd Font', (9889, 9889): 'Symbols Nerd Font', (62076, 62076): 'Symbols Nerd Font', (57507, 57507): 'Symbols Nerd Font', (57524, 57544): 'Symbols Nerd Font', (57546, 57546): 'Symbols Nerd Font', (57548, 57554): 'Symbols Nerd Font', (57556, 57556): 'Symbols Nerd Font', (9211, 9214): 'Symbols Nerd Font', (11096, 11096): 'Symbols Nerd Font', (62208, 62227): 'Symbols Nerd Font', (57344, 57357): 'Symbols Nerd Font'}
tab_bar_edge                       1
tab_bar_style                      powerline
tab_fade                           (0.3, 1.0)
tab_separator                      |
tab_title_template                 {index}: {title}
url_color                          Color(red=131, green=165, blue=152)
Added shortcuts:
	super+d KeyAction(func='new_window', args=())
	super+j KeyAction(func='previous_window', args=())
	super+k KeyAction(func='next_window', args=())
	super+l KeyAction(func='next_layout', args=())
	super+p > f KeyAction(func='kitten', args=['hints', '--type path --program -'])
	super+p > h KeyAction(func='kitten', args=['hints', '--type hash --program -'])
	super+p > l KeyAction(func='kitten', args=['hints', '--type line --program -'])
	super+p > u KeyAction(func='kitten', args=['hints', '--type url --program -'])
	shift+super+minus KeyAction(func='change_font_size', args=(True, '-', 1.0))
	shift+super+0 KeyAction(func='change_font_size', args=(True, None, 0.0))
	shift+super+j KeyAction(func='move_window_backward', args=())
	shift+super+k KeyAction(func='move_window_forward', args=())
Removed shortcuts:
	shift+insert KeyAction(func='paste_from_selection', args=())
	control+tab KeyAction(func='next_tab', args=())
	shift+control+comma KeyAction(func='move_tab_backward', args=())
	shift+control+minus KeyAction(func='change_font_size', args=(True, '-', 2.0))
	shift+control+period KeyAction(func='move_tab_forward', args=())
	shift+control+0 KeyAction(func='tenth_window', args=())
	shift+control+1 KeyAction(func='first_window', args=())
	shift+control+2 KeyAction(func='second_window', args=())
	shift+control+3 KeyAction(func='third_window', args=())
	shift+control+4 KeyAction(func='fourth_window', args=())
	shift+control+5 KeyAction(func='fifth_window', args=())
	shift+control+6 KeyAction(func='sixth_window', args=())
	shift+control+7 KeyAction(func='seventh_window', args=())
	shift+control+8 KeyAction(func='eighth_window', args=())
	shift+control+9 KeyAction(func='ninth_window', args=())
	shift+control+equal KeyAction(func='change_font_size', args=(True, '+', 2.0))
	shift+control+a > 1 KeyAction(func='set_background_opacity', args=['1'])
	shift+control+a > d KeyAction(func='set_background_opacity', args=['default'])
	shift+control+a > l KeyAction(func='set_background_opacity', args=['-0.1'])
	shift+control+a > m KeyAction(func='set_background_opacity', args=['+0.1'])
	shift+control+b KeyAction(func='move_window_backward', args=())
	shift+control+c KeyAction(func='copy_to_clipboard', args=())
	shift+control+e KeyAction(func='kitten', args=['hints'])
	shift+control+f KeyAction(func='move_window_forward', args=())
	shift+control+h KeyAction(func='show_scrollback', args=())
	shift+control+j KeyAction(func='scroll_line_down', args=())
	shift+control+k KeyAction(func='scroll_line_up', args=())
	shift+control+l KeyAction(func='next_layout', args=())
	shift+control+n KeyAction(func='new_os_window', args=())
	shift+control+o KeyAction(func='pass_selection_to_program', args=())
	shift+control+p > f KeyAction(func='kitten', args=['hints', '--type path --program -'])
	shift+control+p > h KeyAction(func='kitten', args=['hints', '--type hash --program -'])
	shift+control+p > l KeyAction(func='kitten', args=['hints', '--type line --program -'])
	shift+control+p > n KeyAction(func='kitten', args=['hints', '--type linenum'])
	shift+control+p > w KeyAction(func='kitten', args=['hints', '--type word --program -'])
	shift+control+p > shift+f KeyAction(func='kitten', args=['hints', '--type path'])
	shift+control+q KeyAction(func='close_tab', args=())
	shift+control+r KeyAction(func='start_resizing_window', args=())
	shift+control+s KeyAction(func='paste_from_selection', args=())
	shift+control+t KeyAction(func='new_tab', args=())
	shift+control+u KeyAction(func='kitten', args=['unicode_input'])
	shift+control+v KeyAction(func='paste_from_clipboard', args=())
	shift+control+w KeyAction(func='close_window', args=())
	shift+control+left_bracket KeyAction(func='previous_window', args=())
	shift+control+right_bracket KeyAction(func='next_window', args=())
	shift+control+grave_accent KeyAction(func='move_window_to_top', args=())
	shift+control+escape KeyAction(func='kitty_shell', args=['window'])
	shift+control+enter KeyAction(func='new_window', args=())
	shift+control+tab KeyAction(func='previous_tab', args=())
	shift+control+backspace KeyAction(func='change_font_size', args=(True, None, 0.0))
	shift+control+delete KeyAction(func='clear_terminal', args=['reset', True])
	shift+control+right KeyAction(func='next_tab', args=())
	shift+control+left KeyAction(func='previous_tab', args=())
	shift+control+down KeyAction(func='scroll_line_down', args=())
	shift+control+up KeyAction(func='scroll_line_up', args=())
	shift+control+page_up KeyAction(func='scroll_page_up', args=())
	shift+control+page_down KeyAction(func='scroll_page_down', args=())
	shift+control+home KeyAction(func='scroll_home', args=())
	shift+control+end KeyAction(func='scroll_end', args=())
	shift+control+f2 KeyAction(func='edit_config_file', args=())
	shift+control+f10 KeyAction(func='toggle_maximized', args=())
	shift+control+f11 KeyAction(func='toggle_fullscreen', args=())
	shift+control+alt+t KeyAction(func='set_tab_title', args=())
	super+plus KeyAction(func='change_font_size', args=(True, '+', 2.0))
	super+minus KeyAction(func='change_font_size', args=(True, '-', 2.0))
	super+0 KeyAction(func='change_font_size', args=(True, None, 0.0))
	super+n KeyAction(func='new_os_window', args=())
	super+r KeyAction(func='start_resizing_window', args=())
	super+enter KeyAction(func='new_window', args=())
	super+down KeyAction(func='scroll_line_down', args=())
	super+up KeyAction(func='scroll_line_up', args=())
	super+page_up KeyAction(func='scroll_page_up', args=())
	super+page_down KeyAction(func='scroll_page_down', args=())
	super+home KeyAction(func='scroll_home', args=())
	super+end KeyAction(func='scroll_end', args=())
	shift+super+d KeyAction(func='close_window', args=())
	shift+super+i KeyAction(func='set_tab_title', args=())
	shift+super+w KeyAction(func='close_os_window', args=())
	shift+super+left_bracket KeyAction(func='previous_tab', args=())
	shift+super+right_bracket KeyAction(func='next_tab', args=())
	alt+super+page_up KeyAction(func='scroll_line_up', args=())
	alt+super+page_down KeyAction(func='scroll_line_down', args=())
Changed shortcuts:
	super+1 KeyAction(func='goto_tab', args=(1,))
	super+2 KeyAction(func='goto_tab', args=(2,))
	super+3 KeyAction(func='goto_tab', args=(3,))
	super+4 KeyAction(func='goto_tab', args=(4,))
	super+5 KeyAction(func='goto_tab', args=(5,))
	super+6 KeyAction(func='goto_tab', args=(6,))
	super+7 KeyAction(func='goto_tab', args=(7,))
	super+8 KeyAction(func='goto_tab', args=(8,))
	super+9 KeyAction(func='goto_tab', args=(9,))
	super+w KeyAction(func='close_window', args=())
	shift+super+equal KeyAction(func='change_font_size', args=(True, '+', 1.0))

Additional context
Reproducible with kitty --config NONE, but problem is less visible because area is black and default background is black

@aslpavel aslpavel added the bug label Aug 6, 2020
kovidgoyal added a commit that referenced this issue Aug 6, 2020
…ck to alternate screen

layer_dirty was being reset if remove_images was called more than once
without an intervening call to update_layers.

Fixes #2901
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant