tramhao / termusic

Music Player TUI written in Rust
GNU General Public License v3.0
1.07k stars 44 forks source link

[Bug] update photo error: Failed to run Ueberzug: Broken pipe (os error 32) #100

Open QuestionMark001 opened 1 year ago

QuestionMark001 commented 1 year ago

Songs cover view don't work.
Operating System: Arch Linux x86_64
Linux Kernel Release: 6.1.1
Ueberzug Version: 18.1.9
Displays this error every time music is played:

截图 2022-12-25 11-09-07

tramhao commented 1 year ago

This means that you need to install ueberzug, which is a python package. paru -S ueberzug

QuestionMark001 commented 1 year ago

Thanks for @tramhao .I installed ueberzug,but cover view still don't work:

截图 2022-12-26 08-53-34
截图 2022-12-26 08-56-54

tramhao commented 1 year ago

Seems strange. Please run it with termusic -c to disable cover display and see if everything works. Broken pipe error should be related to file io. Please check if there is a file cover.jpg exists in here:

                            let mut cache_file =
                                dirs::cache_dir().unwrap_or_else(std::env::temp_dir);
                            cache_file.push("termusic");
                            if !cache_file.exists() {
                                std::fs::create_dir_all(&cache_file)?;
                            }
                            cache_file.push("termusic_cover.jpg");

For me, the location is: ~/.cache/termusic/termusic_cover.jpg

If this file doesn't exist, or not readable by ueberzug, broken pipe will happen.

Basically what I did is that I extract the cover image and save it to cache, then tell ueberzug to draw it. Perhaps a better way is to avoid file io but currently ueberzug only accept file.

hasezoey commented 6 months ago

is this still a issue with termusic v0.9.0 and latest uberzug / uberzugpp?

enrico223 commented 5 months ago

Still an issue on v 0.9.0 even with the file ~/.cache/termusic/termusic_cover.jpg present

hasezoey commented 5 months ago

then if it still is a error and uberzug / uberzugpp is installed, i would need the logs to see whats wrong (hopefully it actually logs it correctly), command is RUST_LOG=debug termusic --log-to-file (will log by default to /tmp/termusic-tui.log, or you can use --log-file /path/to/file.log to set it).

if possible, latest master would be more useful than just v0.9.0 directly if possible.

enrico223 commented 5 months ago

Ueberzug version: 18.2.2-2 Termusic: 0.9.0-1 LOG: Log

Latest master logs: LOGS made with RUST_LOG=debug ./termusic --log-to-file

Tell me if you need anything else

hasezoey commented 5 months ago

thanks, in both the error is the same:

[2024-05-07T21:47:28.256+02:00 ERROR termusic::ui::components::popups::error]: Displaying error popup: update_photo

Caused by:
    0: Failed to run Ueberzug
    1: Broken pipe (os error 32)

will likely need to add more logging to be more specific on what failed (though i forgot to add RUST_BACKTRACE=1 to the command).

from what i can tell, it at least is finding the ueberzug command and executing it, though i dont know enough if the commands that are sent are actually correct.

PS: i can reproduce it locally

hasezoey commented 5 months ago

with #316 i have updated the ueberzug error logging, hopefully being more specific on what has failed (it now print the ueberzug stderr).

Updated recommended command: RUST_BACKTRACE=1 RUST_LOG=debug termusic --log-to-file

note that if your error looks like the following, then that means you are using wayland (and ueberzug only works on x11, from my understanding)

    0: Failed to run Ueberzug
    1: ueberzug command failed, (code Some(1), signal None), stderr:
       X Error of failed request:  BadDrawable (invalid Pixmap or Window parameter)
         Major opcode of failed request:  14 (X_GetGeometry)
         Resource id in failed request:  0x1
         Serial number of failed request:  425
         Current serial number in output stream:  425

Note: covers are available on wayland too, but only if your terminal supports protocol sixel and feature cover / cover-viuer-sixel is enabled

enrico223 commented 5 months ago

Just to add on your comment, running termusic on Wayland on kitty terminal doesn't have any problem. OS error 32 shows up with alacritty on Wayland since it doesn't support sixel protocol. The following is the log from the latest master

[2024-05-08T15:33:22.424+02:00 ERROR termusic::ui::components::popups::error]: Displaying error popup: update_photo

Caused by:
    0: Failed to run Ueberzug
    1: Broken pipe (os error 32)

Stack backtrace:
   0: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
   1: termusiclib::ueberzug::UeInstance::run_ueberzug_cmd
   2: termusiclib::ueberzug::UeInstance::clear_cover_ueberzug
   3: termusic::ui::components::xywh::<impl termusic::ui::model::Model>::clear_photo
   4: termusic::ui::components::xywh::<impl termusic::ui::model::Model>::update_photo
   5: termusic::ui::model::Model::player_update_current_track_after
   6: termusic::ui::UI::handle_current_track_index
   7: termusic::ui::UI::run_playback::{{closure}}
   8: termusic::actual_main::{{closure}}
   9: tokio::runtime::park::CachedParkThread::block_on
  10: tokio::runtime::context::runtime::enter_runtime
  11: termusic::main
  12: std::sys_common::backtrace::__rust_begin_short_backtrace
  13: std::rt::lang_start::{{closure}}
  14: std::rt::lang_start_internal
  15: main
  16: <unknown>
  17: __libc_start_main
  18: _start
hasezoey commented 5 months ago

OS error 32 shows up with alacritty on Wayland since it doesn't support sixel protocol. The following is the log from the latest master

that is kinda to be expected, ueberzug only works on x11, not on wayland (regardless of terminal, unless maybe the terminal itself runs via xwayland)

enrico223 commented 5 months ago

Does this error only occur on wayland then?

hasezoey commented 5 months ago

Does this error only occur on wayland then?

well if your stderr is the following, then yes (at least as far as i understand ueberzug):

    0: Failed to run Ueberzug
    1: ueberzug command failed, (code Some(1), signal None), stderr:
       X Error of failed request:  BadDrawable (invalid Pixmap or Window parameter)
         Major opcode of failed request:  14 (X_GetGeometry)
         Resource id in failed request:  0x1
         Serial number of failed request:  425
         Current serial number in output stream:  425

(note that this is only visible with #316)