joouha / euporie

Jupyter notebooks in the terminal
https://euporie.readthedocs.io
MIT License
1.54k stars 36 forks source link

euporie-console stuck (unresponsive) for a long time on simple plots #77

Closed IndianBoy42 closed 1 year ago

IndianBoy42 commented 1 year ago

I just used the simple plot example from Matplotlib to test out Eupories capabilities:

It immediately gets stuck, completely unresponsive, with any keypresses resulting in the raw keycodes being printed on screen. top or any process monitor shows me that the euporie python process is maxing out one of my cores. And the log with log-level=debug shows that the last line is:

2023-05-27 17:18:59 DEBUG   [euporie.core.convert.core._convert:242] Converting from 'ansi' to 'formatted_text' using route: [['ansi', 'formatted_text']]
2023-05-27 17:19:42 DEBUG   [euporie.core.convert.core._convert:242] Converting from 'base64-png' to 'png' using route: [['base64-png', 'png']]
2023-05-27 17:19:42 DEBUG   [euporie.core.convert.core._convert:242] Converting from 'base64-png' to 'formatted_text' using route: [['base64-png', 'png', 'ansi', 'formatted_text'], ['base64-png', 'png', 'pil', 'ansi', 'formatted_text']]
2023-05-27 17:19:42 DEBUG   [euporie.core.convert.utils.call_subproc:95] Running external command `['viu', '-w', '49', '-s', '-']`

Trying to create/convert(?) the image with viu, which obviously is actually quite fast when run manually.

Any idea what is wrong?

(Using Kitty terminal and kitty graphics)

IndianBoy42 commented 1 year ago

The same happens in notebook

joouha commented 1 year ago

Hi,

I think that possibly viu was detecting that your terminal supports kitty graphics and was trying to return kitty graphics rather than block graphics which euporie expects.

Anyway, I've fixed this by adding the -b flag when calling viu for force block graphics output.

I've made a new release with the fix (v2.4.2) which you can try.

IndianBoy42 commented 1 year ago

Interesting, I'll try it once I get back, but if I have kitty graphics shouldnt it be using kitty graphics? Or am I misunderstanding how it's used

IndianBoy42 commented 1 year ago

This works now, thanks!

joouha commented 1 year ago

Interesting, I'll try it once I get back, but if I have kitty graphics shouldnt it be using kitty graphics? Or am I misunderstanding how it's used

Euporie generates both block-graphics and terminal graphics (if supported). The block-graphics rendering is used as a fall-back, and is displayed when a UI element such as a menu or dialog box could overlap an image, as most terminals do not support text over graphics.

Euporie does not need an external tool to convert images for display using the kitty graphics protocol, but will use external tools (viu is one of several options) for block-graphics rendering if one is available which is faster / better than the available Python implementation.