Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Chafa functionality inconsistent #1339

Closed
RainOrigami opened this issue Oct 20, 2019 · 5 comments
Closed

Chafa functionality inconsistent #1339

RainOrigami opened this issue Oct 20, 2019 · 5 comments
Labels

Comments

@RainOrigami
Copy link

Description

Running neofetch through an SSH connection using chafa sometimes causes "Image: Failed to find terminal window size.". I can run the command ten times in a row and maybe two times it wouldn't work. When it fails it would do a bell sound (\a) and also leave the string "1350;630t" in the next bash line.

In the 6.0.0 screenshot you can see that it worked and then it suddenly didn't, just by running the exact same command.

I tried the latest release 6.1.0 to see if it was maybe fixed but couldn't get chafa to work at all, with the same error message but no bell or additional string in the next line. Not sure if that's related.

Neofetch version

6.0.0

Screenshot

6.0.0 https://i.imgur.com/d5KYEX9.png
6.1.0 https://i.imgur.com/sHTB0vI.png

Config file

https://pastebin.com/cccuXC8T

Verbose log

6.0.0 https://pastebin.com/knYNHqQn
6.1.0 https://pastebin.com/uk4hPpQJ

@dylanaraps dylanaraps added the Bug label Oct 20, 2019
@hpjansson
Copy link
Contributor

@Longoon12000 Is it a high/variable latency link? FWIW I think Neofetch expects to get a response from the client terminal emulator in less than one second. The timeout seems to be consistent with it working sometimes and sometimes not.

I doubt this is a bug in Chafa. Does it work consistently with other image-to-text backends?

@RainOrigami
Copy link
Author

RainOrigami commented Oct 21, 2019

Is it a high/variable latency link?

High latency, no (15ms ping + whatever it takes for ssh to encrypt and decrypt), but variable, definitely. I also noticed that it's most prominent at the beginning of an ssh session with declining frequency.

I think Neofetch expects to get a response from the client terminal emulator in less than one second.

I'm not sure how this works through SSH. Neofetch doesn't poll my actual terminal emulator where I'm running SSH on the client for the size but rather whatever bash is running on the server, right?
If there is a way to change the timeout I would test whether it would still happen or not.

I doubt this is a bug in Chafa.

Chafa by itself works fine all the time but you're right that it's not only related to Chafa in neofetch:

Does it work consistently with other image-to-text backends?

According to the Images Backends documentation these are image-to-text backends:

  • caca (same inconsistency and error)
  • catimg (produces default distribution ascii logo instead of image with no obvious error): log
  • jp2a (same inconsistency and error)
  • pixterm (has no ubuntu package and I'm too lazy to install a whole Go dev env to build it, sorry)

The others (iTerm2, Sixel, Tycat, W3m) aren't image-to-text and wouldn't work over ssh anyways I think.

So it's definitely not only Chafa related but a general issue on an SSH connection. I couldn't reproduce this issue on my local machine.

As a workaround I have stored the chafa output in a text file and provided this to --ascii. This works fine (except I need a gap of -985 wth?) and I don't really need to re-generate the ascii image every time neofetch runs anyways. However this wouldn't solve this issue if someone would want to generate ascii from a dynamic image (except by always running chafa before neofetch).

@hpjansson
Copy link
Contributor

hpjansson commented Dec 4, 2019

@Longoon12000 Sorry for getting back to this so late, I was traveling and then it fell off my radar.

I think Neofetch expects to get a response from the client terminal emulator in less than one second.

I'm not sure how this works through SSH. Neofetch doesn't poll my actual terminal emulator where I'm running SSH on the client for the size but rather whatever bash is running on the server, right?
If there is a way to change the timeout I would test whether it would still happen or not.

That's exactly what happens -- it sends an escape code that's received by your terminal emulator, and it's supposed to send its window size back. Neofetch waits for up to a second (actually .05 seconds on modern bash) for the round trip to happen, and if the response doesn't arrive within that interval, it will assume the escape code is unsupported.

See this line in Neofetch master. Change the -t 0.05 (and -t 1 on the subsequent line just to make sure) arguments to read to -t 10 (10 seconds) and see if the problem goes away.

TBF I think Neofetch wrongly rules out Chafa and other character cell-based image backends if it fails to get the window pixel size. It could guess at the character cell size instead (1:2 aspect ratio is the default fallback in Chafa and it's usually not too far off).

@dylanaraps
Copy link
Owner

See: #1392

@hpjansson
Copy link
Contributor

@dylanaraps Would you accept a PR to increase the bash timeouts here:

neofetch/neofetch

Line 4241 in b3e21d8

4|5) IFS=';t' read -d t -t 0.05 -sra term_size ;;

The issue is that it needs a little more time if you're running neofetch on a remote host. 5 seconds would probably cover most cases, and it shouldn't add any delay for most users as the timeout only comes into play if there is no response from the terminal.

hpjansson added a commit to hpjansson/neofetch that referenced this issue Aug 31, 2021
Remote or just generally slow sessions could have too high latency
for the terminal response to get through before the timeout,
rendering in-terminal image backends unusable. Increase the timeout
to accommodate these.

See dylanaraps#1339.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants