itsjunetime / tdf

A tui-based PDF viewer
Mozilla Public License 2.0
297 stars 5 forks source link

[Bug] Couldn't render a page - Couldn't paint Context: Invalid Matrix #1

Closed mcxiv closed 1 month ago

mcxiv commented 1 month ago

Hello there,

tdf looks fantastic! Good job!

I saw that someone reported the same issue as me on Reddit and hasn't created the issue yet, so, here I am.


I am using Terminator, and, for any PDF file I'm trying, I am getting the error "Couldn't render a page: Couldn't render page: Couldn't paint Context: Invalid Matrix"

image

You mentioned the fact that it could be because of terminator, but I am getting the same error on the Manjaro (gnome) default terminal. (Works well on kitty tho)

Thanks, Quentin

itsjunetime commented 1 month ago

So I tried this out on terminator and it seems that terminator implements TIOCGWINSZ incorrectly, returning a width and height of 0 for the window size instead of reporting them correctly. This makes it so that we can't determine the 'font size' of the window, which is necessary for ratatui_image to display images correctly.

I could provide a configuration option to allow users to manually input the font size for their terminal, but unfortunately this still won't allow full functionality with these terminal emulators - neither terminator or gnome-terminal (referenced in another issue) support images of any type (the gnome-terminal issue can be found here, but I can't find any discussion of the terminator issue from official sources), so even if this issue was worked around, this tool still would not be fully functional.

I would like to keep this issue open, though, as I expect there are ways to work around the terminal size being reported incorrectly, or at least provide a better error.

dashingdon commented 1 month ago

it was me who reported in reddit, @mcxiv. thank you for opening the issue here.

I blurred the file name at the top. rest is direct output of tdf

dashingdon commented 1 month ago

@itsjunetime @mcxiv will you be able to share your kitty configuration? I am trying to get it working on kitty (I am using default kitty config). Attached are my current laptop specs (if helpful)

image

itsjunetime commented 1 month ago

Before I share my config (as I don't think kitty has any options in the config that change image support), @dashingdon would you be able to paste the output of running kitty +kitten icat --detect-support; echo "$?" in a running instance of kitty?

dashingdon commented 1 month ago

kitty +kitten icat --detect-support; echo "$?"

file0

crookedmirror commented 1 month ago

Getting same issue on Sakura terminal here.

dashingdon commented 1 month ago

@itsjunetime quick update re Kitty I updated the version to latest (0.35 link). debian repo version was 0.26.5

kitty works great. thank you.

joseg-alvesg commented 1 month ago
  • xterm - loads it quickly but the content is all fuzzy image

The same happens in alacritty

image

itsjunetime commented 1 month ago

With regard to alacritty, please read this comment: https://github.com/itsjunetime/tdf/issues/3#issuecomment-2138000680; however, it seems xterm might be having a different issue, as it should support sixel (as per https://www.arewesixelyet.com/#xterm). @dashingdon would you be able to open another issue for the xterm fuzziness (as it should work fine there)?

I'd like to keep this issue on the topic of, specifically, the 'Invalid Matrix' error. If anyone has suggestions for what to do about that error (after reading my comments in https://github.com/itsjunetime/tdf/issues/1#issuecomment-2138019290), I would appreciate that being discussed here.

dashingdon commented 1 month ago

@dashingdon would you be able to open another issue for the xterm fuzziness (as it should work fine there)?

4 Done :heavy_check_mark:

itsjunetime commented 1 month ago

I just pushed https://github.com/itsjunetime/tdf/commit/017596a8b0745a6da7c3c75a5f55073b82202a5c, which fixes this issue for me on terminator (of course, it still shows up as blurry halfblocks due to the lack of image support, but at least it doesn't report the invalid matrix); @mcxiv could you confirm that this issue is now not present?

dashingdon commented 1 month ago

I just pushed https://github.com/itsjunetime/tdf/commit/017596a8b0745a6da7c3c75a5f55073b82202a5c, which fixes this issue for me on terminator

I confirm that file renders (fuzzy as expected) but no invalid matrix error

image

dashingdon commented 1 month ago

also fyi looks like sixel support has been enabled for terminator. not sure how to activate/enable it

itsjunetime commented 1 month ago

According to https://github.com/fastfetch-cli/fastfetch/issues/683#issuecomment-1890576703, terminator does have sixel support iff the underlying vte (i think that stands for virtual terminal emulator? maybe?) was compiled with sixel support. I'm guessing, then, that the default underlying vte does not have sixel support and you'd need to do a custom build to get that.

Also, since the titular issue here has been resolved, I'm going to close this issue.