Closed aslpavel closed 3 years ago
I've also noticed if you try to show img2sixel squirrel.sixel
image around 60 times, terminal becomes unresponsive for a while, and all subsequent renders will draw blank space with the color of the default terminal background color.
I haven't had an opportunity to dig into this, and I do want to see this improve, but in the meantime I thought you'd appreciate some background on how image support is implemented in wezterm:
At the parser layer:
Arc
(shared pointer)ImageCell
that holds a ref on the image data as well as texture coordinates for the relevant portion of the image that should be rendered in that cell. That decision is based on the known cell size associated with the pty, which is an integer value.The image data here is immutable so it is unlikely that it is being literally corrupted.
At the render layer:
Something wonky with the texture coordinates at this stage might cause data to bleed in from neighboring data in the texture atlas; I think that might explain the fractals that appear at the bottom of your final image.
The "missing scan lines" are most likely an artifact of mapping the image to terminal cells some imperfect math/rounding issue in computing texture coordinates.
I suspect that you'd see improved results with a slightly different font size.
I think that might explain the fractals that appear at the bottom of your final image.
Fractals are from subsequent calls (that is I was rendering fractal animation after rendering squirrel), point here it is somehow ended up updating already rendered image, probably by using incorrect atlas coordinates
Another interesting point is querying terminal size with ioctl TIOCGWINSZ will report:
TerminalSize { cells: Size { height: 30, width: 229 }, pixels: Size { height: 1018, width: 2977 } }
If you convert it to cell size it will result in fractional value: height=33.933333... width=13
In master, with the revised texture atlas allocation algorithm, the "corruption" case is very easy to trigger:
cd libsixel
cat images/snake.six
wezterm imgcat images/egret.jpg
The top few pixels of egret.jpg now appear in the bottom few pixels (after a padding break) of the snake graphic. This is due to the bottom few pixels of snake being smaller than the cell height. This is something wonky with the texture coordinates selected for the bottom row.
(you can also reproduce by cat'ing snake twice)
I believe that both the scaling and the bleed-through are resolved in master; at least it appears to work for me. I'd appreciate it if you could give it a try when you have a chance!
Thank you for the fix, but I was not able to check if it is working. I'm using MacOS and apparently 91ce0b77eaab95b94432b5a0379d64129e07f3e7 breaks it for me. It is panics with 'No OpenGL' previous revision works fine. It produces the following error:
2020-10-24T23:15:43.291Z ERROR wezterm::gui::termwindow > scale changed so resize to RowsAndCols { rows: 24, cols: 80 } Dimensions { pixel_width: 1134, pixel_height: 900, dpi: 192 }
2020-10-24T23:15:43.340Z WARN window::os::macos::window::opengl > EGL init failed: with_egl_lib failed: /Users/aslpavel/wezterm/target/release/libEGL.dylib: dlopen(/Users/aslpavel/wezterm/target/release/libEGL.dylib, 2): image not found, libEGL.dylib: dlopen(libEGL.dylib, 2): image not found, /Users/aslpavel/wezterm/target/release/libEGL.dylib: dlopen(/Users/aslpavel/wezterm/target/release/libEGL.dylib, 2): image not found, libEGL.dylib: dlopen(libEGL.dylib, 2): image not found, falling back to CGL
2020-10-24T23:15:44.899Z INFO wezterm::gui::renderstate > compiling a prog with version 330
2020-10-24T23:15:44.899Z INFO wezterm::gui::renderstate > compiling a prog with version 300 es
2020-10-24T23:15:44.899Z ERROR wezterm::gui::termwindow > failed to create OpenGLRenderState: Failed to compile shaders: Compilation error in vertex shader: ERROR: 0:4: 'attribute' : syntax error: syntax error
Compilation error in vertex shader: ERROR: 0:1: '' : version '300' is not supported
ERROR: 0:1: '' : syntax error: #version
ERROR: 0:2: '' : #version required and missing.
ERROR: 0:4: 'attribute' : syntax error: syntax error
thread 'main' panicked at 'No OpenGL', wezterm/src/gui/termwindow.rs:720:41
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at 'cannot access a Thread Local Storage value during or after destruction: AccessError', /Users/aslpavel/.rustup/toolchains/stable-x86_64-apple-darwin/lib/rustlib/src/rust/library/std/src/thread/local.rs:241:26
2020-10-24T23:15:45.002Z ERROR mux > read_pty EOF: pane_id 0
fatal runtime error: failed to initiate panic, error 5
Abort trap: 6
doh, thanks for reporting that! I'll revert that portion of the change :-/
It looks like fix works, I no longer see any corruptions. Thank you for the fix.
Thanks for confirming!
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Describe the bug
There are two issues probably related
Environment (please complete the following information):
To Reproduce
All of this is not specific to this image, in general if you render one image after another previous images are corrupted, and scaling is always weird
Configuration
Expected behavior
ITerm output as a reference
Session Recording
20201009110114.tgz
Additional examples where corruption is more visible