rust-av / ssimulacra2_bin

Binary interface for the ssimulacra2 Rust port
BSD 2-Clause "Simplified" License
40 stars 10 forks source link

Unable to generate graph for video inputs #39

Closed tbejos closed 3 months ago

tbejos commented 4 months ago

Hello, I have been unable to get the graphing feature (-g) to work on Arch Linux. The command I used was ssimulacra2_rs video source.mkv encoded.mkv -g -f 20. I have made sure install all the dependencies listed in the README but I run into a panic from the plotters library. I initially tried using the AUR package but when I ran into this issue I attempted to clone from GitHub and build manually. I used cargo --frozen --release to build, I made one change to the Cargo.toml to get more information in the backtrace.

 [profile.release]
 lto = "thin"
 codegen-units = 1
+debug=true

Here is the backtrace I got using RUST_BACKTRACE=full, it appears to be a font issue of some kind. I installed some additional fonts along the way (and rebuilt font cache and restarted a few times as well) but that did not seem to resolve the issue. I believe only stack frames 15-25 are relevant but I posted the full backtrace just in case.

thread 'main' panicked at /home/tbejos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/plotters-0.3.5/src/style/font/mod.rs:75:9:
The font implementation is unable to draw text
stack backtrace:
   0:     0x5ddfbcbcd70b - std::backtrace_rs::backtrace::libunwind::trace::h3a9fba4a6e9efa3f
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x5ddfbcbcd70b - std::backtrace_rs::backtrace::trace_unsynchronized::h1b343a341f1987fa
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x5ddfbcbcd70b - std::sys_common::backtrace::_print_fmt::h1e2e48e8548e08f3
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x5ddfbcbcd70b - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2fe490803af88cd5
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x5ddfbca6d9b0 - core::fmt::rt::Argument::fmt::hd7b7dd73d09b2e4a
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/core/src/fmt/rt.rs:142:9
   5:     0x5ddfbca6d9b0 - core::fmt::write::h0e806f9ceb53dc01
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/core/src/fmt/mod.rs:1120:17
   6:     0x5ddfbcbcb392 - std::io::Write::write_fmt::hc993ca4907c5591c
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/io/mod.rs:1846:15
   7:     0x5ddfbcbcd4a4 - std::sys_common::backtrace::_print::haba7adce0567c729
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x5ddfbcbcd4a4 - std::sys_common::backtrace::print::h7188c066e4378df6
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x5ddfbcbcee40 - std::panicking::default_hook::{{closure}}::hdc0fc6164adc38ae
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/panicking.rs:272:22
  10:     0x5ddfbcbceb5f - std::panicking::default_hook::h42848e1a5516cbc3
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/panicking.rs:292:9
  11:     0x5ddfbcbcf35e - std::panicking::rust_panic_with_hook::h37f14317b32091f5
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/panicking.rs:781:13
  12:     0x5ddfbcb51f1d - std::panicking::begin_panic::{{closure}}::hfdf0a5695ea254f4
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/panicking.rs:689:9
  13:     0x5ddfbcb45036 - std::sys_common::backtrace::__rust_end_short_backtrace::h4ae1d371af835fb6
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/sys_common/backtrace.rs:171:18
  14:     0x5ddfbca0ea2a - std::panicking::begin_panic::h0729d57528276add
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/panicking.rs:688:12
  15:     0x5ddfbcb7828f - plotters::style::font::FontData::draw::h2f2fdc16719b9fe7
                               at /home/tbejos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/plotters-0.3.5/src/style/font/mod.rs:75:9
  16:     0x5ddfbcb7828f - plotters::style::font::font_desc::FontDesc::draw::ha43101427b481abe
                               at /home/tbejos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/plotters-0.3.5/src/style/font/font_desc.rs:168:29
  17:     0x5ddfbcb7828f - <plotters::style::text::TextStyle as plotters_backend::text::BackendTextStyle>::draw::h4e91a0ba26ad7a7e
                               at /home/tbejos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/plotters-0.3.5/src/style/text.rs:322:9
  18:     0x5ddfbcb7828f - plotters_backend::DrawingBackend::draw_text::h5e700ae2755da5e6
                               at /home/tbejos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/plotters-backend-0.3.5/src/lib.rs:250:15
  19:     0x5ddfbcb7828f - plotters::drawing::area::DrawingArea<DB,plotters::coord::Shift>::titled::{{closure}}::h8751180af9f91d0d
                               at /home/tbejos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/plotters-0.3.5/src/drawing/area.rs:496:13
  20:     0x5ddfbcb7828f - plotters::drawing::area::DrawingArea<DB,CT>::backend_ops::h0835a25e43ebb6ae
                               at /home/tbejos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/plotters-0.3.5/src/drawing/area.rs:282:13
  21:     0x5ddfbcb7828f - plotters::drawing::area::DrawingArea<DB,plotters::coord::Shift>::titled::h8fccb641644ba503
                               at /home/tbejos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/plotters-0.3.5/src/drawing/area.rs:495:9
  22:     0x5ddfbcb7828f - plotters::chart::builder::ChartBuilder<DB>::build_cartesian_2d::ha4e0469ed722b6be
                               at /home/tbejos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/plotters-0.3.5/src/chart/builder.rs:332:28
  23:     0x5ddfbcb94c61 - ssimulacra2_rs::video::compare_videos_inner::hd282572a05a9f33a
                               at /home/tbejos/Videos/testing/ssimulacra2_bin/src/video.rs:454:29
  24:     0x5ddfbcb94c61 - ssimulacra2_rs::video::compare_videos::h35e00759f84ce118
                               at /home/tbejos/Videos/testing/ssimulacra2_bin/src/video.rs:263:5
  25:     0x5ddfbcb9ebc9 - ssimulacra2_rs::main::h5dfd29969b29ba45
                               at /home/tbejos/Videos/testing/ssimulacra2_bin/src/main.rs:134:13
  26:     0x5ddfbcb45043 - core::ops::function::FnOnce::call_once::hcb9495672c777a38
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/core/src/ops/function.rs:250:5
  27:     0x5ddfbcb45043 - std::sys_common::backtrace::__rust_begin_short_backtrace::h1a0b6f9ea116d60a
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/sys_common/backtrace.rs:155:18
  28:     0x5ddfbcb4e5f9 - std::rt::lang_start::{{closure}}::h7ab8da793ff261eb
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/rt.rs:166:18
  29:     0x5ddfbcbc3025 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h6a5f00ab1c581878
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/core/src/ops/function.rs:284:13
  30:     0x5ddfbcbc3025 - std::panicking::try::do_call::h710f22b7f4c6868f
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/panicking.rs:554:40
  31:     0x5ddfbcbc3025 - std::panicking::try::h4011a8d70837f180
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/panicking.rs:518:19
  32:     0x5ddfbcbc3025 - std::panic::catch_unwind::h46d9bc1e1fef08b6
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/panic.rs:142:14
  33:     0x5ddfbcbc3025 - std::rt::lang_start_internal::{{closure}}::h876504adee55eae2
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/rt.rs:148:48
  34:     0x5ddfbcbc3025 - std::panicking::try::do_call::hcbcce42fa17f59ba
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/panicking.rs:554:40
  35:     0x5ddfbcbc3025 - std::panicking::try::hf60b1f3f8d6a4862
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/panicking.rs:518:19
  36:     0x5ddfbcbc3025 - std::panic::catch_unwind::h9e9ddc06c0f56cbe
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/panic.rs:142:14
  37:     0x5ddfbcbc3025 - std::rt::lang_start_internal::he5e87cd982b6a812
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/rt.rs:148:20
  38:     0x5ddfbcbabcac - main
  39:     0x72c72cb1bcd0 - <unknown>
  40:     0x72c72cb1bd8a - __libc_start_main
  41:     0x5ddfbca14dd5 - _start
  42:                0x0 - <unknown>

Is there a dependency that I am missing? From what I can tell I believe I have followed all of the steps to build as intended. Has anyone else been able to graph successfully recently, or is this not an issue for anyone else? Thanks!

FreezyLemon commented 4 months ago

I can reproduce this. Maybe it's because of the "sans-serif" font being used? I don't have a font with that exact name installed

tbejos commented 4 months ago

I see that in the README it has ttf-bitstream-vera as a dependency but I can see that isn't the default font on my system

$ fc-match "sans-serif"
NotoSans-Regular.ttf: "Noto Sans" "Regular"

maybe that is related? Although maybe you can't just match based on font-family like you mention

FreezyLemon commented 4 months ago

I'll be honest, I don't know much about how fonts are selected/loaded. If fc-match correctly represents the font selection done by the system, I'd honestly expect "sans-serif" to just work given that it also returns a font for me.

tbejos commented 4 months ago

Okay so I was able to fix it by making the following change, however it made some changes to Cargo.lock as well, I am not familiar with rust development, if I make a PR should I also include the changes to Cargo.lock, or is that auto-generated/populated by something like GitHub Actions?

diff --git a/Cargo.toml b/Cargo.toml
index 6c2e003..55ee868 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -31,7 +31,7 @@ features = ["png", "jpeg", "webp", "hdr", "exr"]
 [dependencies.plotters]
 version = "0.3.4"
 default-features = false
-features = ["bitmap_backend", "area_series"]
+features = ["bitmap_backend", "area_series", "ttf"]
 optional = true

 [profile.release]

Based on this change fixing it looks like the issue is that it might not support ttf fonts by default, I wonder if setting the default to a bitmap font instead would work. I am not sure if this would break it for people using non-ttf fonts or not

FreezyLemon commented 4 months ago

if I make a PR should I also include the changes to Cargo.lock, or is that auto-generated/populated by something like GitHub Actions?

Yes, please add those aswell. There's no auto-updater on this repo, and the change to Cargo.lock is directly caused by your change to the Cargo.toml file, so it's part of the change.