gokcehan / lf

Terminal file manager
MIT License
7.8k stars 330 forks source link

lf image preview flickering #1738

Open youpilai opened 5 months ago

youpilai commented 5 months ago

Hi,

Similar to closed issue #1689 , image is flickering when loaded, when swapping workspace, when copy, cut or paste I tried to put an echo command in my preview script, but it is not triggered multiple time, only when changing the file to be previewed (moving up and down) I tested with minimal lfrc and preview files to see if it was in my config with no difference

the command used to preview images is the commonly used : chafa -f sixel -s "$2x$3" --animate off --polite on "$1"

lf -version = r32 (32-1) chafa --version = 1.14.0 foot -v = 1.17.2 +pgo +ime +graphemes -assertions

Edit : i just saw #1665 : i tried with and without "set period 1" with no difference. In my case the image flicker only once when loaded for the first time or when an action is done : copy/cut/paste

Kuchteq commented 5 months ago

Facing similar issue. Went back to version 31-1 to test if it has always been the case but there there's no flicker

joelim-work commented 5 months ago

Hi, it looks like the issue is because some time after version r31, the tcell dependency was upgraded, and is no longer compatible with the original Sixel implementation. I tried to rewrite the code in #1744, would you be able to try it out and see if there's an improvement with the flickering?

Hopefully it works, but if not then I'm not sure what can be done.

youpilai commented 5 months ago

it seems to be working for me, there is no longer flickering when previewing images (moving up and down through files in lf), nor when swapping workspace

there is still a flickering when performing an action (copy/cut) on a file, but it can be seen as a visual hint that you performed the action

Nice and quick work, i'll keep my local version until this commit merge to master

Edit: in fact, when in full screen, the flickering is still present, but less than before, and sometimes the previous is not cleaned (if the new preview is smaller than the previous, you'll see a part of the latter remaining)

joelim-work commented 5 months ago

Interestingly I couldn't reproduce most of the above when I tried using foot just now, but that was with the default settings without any configuration, since I don't actually use that terminal. But very occasionally I do see random things like flickering, part of the preview not being cleaned up properly, artefacts when resizing the terminal, etc.

I think it might not be feasible to fix every Sixel-related issue though. While there is an escape sequence for writing Sixel images, cleaning them up is implemented by setting the value of each cell in the preview window to a blank character, and it may not work reliably depending on which terminal you use.

As for the PR, I might leave it open for a while to get more feedback, especially on the actual changes to the code. I will consider merging it if the overall experience is improved, but I also don't expect it to be perfect.

youpilai commented 5 months ago

after some use, it appears the cleaning problem is just on the first load of an image taller than the next one (i don't use cache for thumbnails, they are created on the fly via chafa)

Anyway, for now it is absolutely usable to me, i'll keep the locally patched version and wait to see if it's merged one day

Thanks