Inlyne-Project / inlyne

Introducing Inlyne, a GPU powered yet browserless tool to help you quickly view markdown files in the blink of an eye.
MIT License
1.09k stars 27 forks source link

Panic when window returns no surface capabilities #158

Open CosmicHorrorDev opened 1 year ago

CosmicHorrorDev commented 1 year ago

No luck so far with 'inlyne'.

Every markdown I try, including this crates' README.md, yields an 'index out of bounds'.

I tried inlyne 0.3.1 as released on crates.io and current ( #817a385 ) git. The latter I built with both nightly and stable rust, no difference seen.

cargo r README.md 
    Finished dev [unoptimized + debuginfo] target(s) in 0.12s
     Running `target/debug/inlyne README.md`
thread 'main' panicked at src/renderer.rs:113:36:
index out of bounds: the len is 0 but the index is 0
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Backtrace:

    Finished dev [unoptimized + debuginfo] target(s) in 0.13s
     Running `target/debug/inlyne README.md`
thread 'main' panicked at src/renderer.rs:113:36:
index out of bounds: the len is 0 but the index is 0
stack backtrace:
   0: rust_begin_unwind
             at /rustc/07688726805d5db0a4bca445a6651d09708041ea/library/std/src/panicking.rs:617:5
   1: core::panicking::panic_fmt
             at /rustc/07688726805d5db0a4bca445a6651d09708041ea/library/core/src/panicking.rs:67:14
   2: core::panicking::panic_bounds_check
             at /rustc/07688726805d5db0a4bca445a6651d09708041ea/library/core/src/panicking.rs:162:5
   3: <usize as core::slice::index::SliceIndex<[T]>>::index
             at /rustc/07688726805d5db0a4bca445a6651d09708041ea/library/core/src/slice/index.rs:261:10
   4: core::slice::index::<impl core::ops::index::Index<I> for [T]>::index
             at /rustc/07688726805d5db0a4bca445a6651d09708041ea/library/core/src/slice/index.rs:18:9
   5: <alloc::vec::Vec<T,A> as core::ops::index::Index<I>>::index
             at /rustc/07688726805d5db0a4bca445a6651d09708041ea/library/alloc/src/vec/mod.rs:2675:9
   6: inlyne::renderer::Renderer::new::{{closure}}
             at ./src/renderer.rs:113:36
   7: pollster::block_on
             at /home/luuk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/pollster-0.3.0/src/lib.rs:128:15
   8: inlyne::Inlyne::new
             at ./src/main.rs:198:24
   9: inlyne::main
             at ./src/main.rs:783:18
  10: core::ops::function::FnOnce::call_once
             at /rustc/07688726805d5db0a4bca445a6651d09708041ea/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Anything I should try?

Thanks in advance!

Originally posted by @luukvanderduim in https://github.com/trimental/inlyne/issues/70#issuecomment-1684294973

CosmicHorrorDev commented 1 year ago

That's a new one for me @luukvanderduim. It looks like the window for inlyne isn't returning any surface capabilities which makes sense as to why it fails on every markdown file you try

Are you running on a pretty esoteric system?

luukvanderduim commented 1 year ago

Would not say so.. I am using the following:

System:
  Host: kubus Kernel: 6.2.0-27-generic arch: x86_64 bits: 64 Desktop: Xfce
    v: 4.18.1 Distro: Ubuntu 23.04 (Lunar Lobster)
Machine:
  Type: Desktop System: Gigabyte product: B550I AORUS PRO AX v: N/A
    serial: <superuser required>
  Mobo: Gigabyte model: B550I AORUS PRO AX serial: <superuser required>
    UEFI: American Megatrends LLC. v: F17b date: 02/08/2023
CPU:
  Info: 8-core model: AMD Ryzen 7 5700G with Radeon Graphics bits: 64
    type: MT MCP cache: L2: 4 MiB
  Speed (MHz): avg: 1850 min/max: 1400/4672 cores: 1: 1400 2: 1400 3: 1400
    4: 3800 5: 1400 6: 1400 7: 3800 8: 1400 9: 1400 10: 1400 11: 1400 12: 1400
    13: 1400 14: 1400 15: 3800 16: 1400
Graphics:
  Device-1: AMD Cezanne [Radeon Vega Series / Radeon Mobile Series]
    driver: amdgpu v: kernel
  Display: x11 server: X.Org v: 1.21.1.7 driver: X: loaded: amdgpu
    unloaded: fbdev,modesetting,vesa dri: radeonsi gpu: amdgpu
    resolution: 3440x1440
  API: OpenGL v: 4.6 Mesa 23.0.4-0ubuntu1~23.04.1 renderer: AMD Radeon
    Graphics (renoir LLVM 15.0.7 DRM 3.49 6.2.0-27-generic)

Pretty common hardware. The only thing I can think of that might be related - but I am not sure if that is relevant - is that I've enabled 10 bit colour in X11.

CosmicHorrorDev commented 1 year ago

Not as odd as I was expecting. Well if you want to troubleshoot a bit I would see if you can run some of the examples (like mipmap or cube) in the gfx-rs/wgpu repo and see if they fail as well

I can also dig in more this weekend, but I'll have to see if I have a monitor with 10-bit support

luukvanderduim commented 1 year ago

Hmm..

     Running `target/debug/cube`
Using AMD Radeon Graphics (RADV RENOIR) (Vulkan)
thread 'main' panicked at 'Surface isn't supported by the adapter.', code/wgpu/examples/common/src/framework.rs:275:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

and

   Compiling wgpu-mipmap-example v0.17.0 (/home/luuk/code/wgpu/examples/mipmap)
    Finished dev [unoptimized + debuginfo] target(s) in 1.23s
     Running `target/debug/mipmap`
Using AMD Radeon Graphics (RADV RENOIR) (Vulkan)
thread 'main' panicked at 'Surface isn't supported by the adapter.', /home/luuk/code/wgpu/examples/common/src/framework.rs:275:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I'll try and go back to 8 bit, to confirm our suspicion (if only I remembered where I configured it ;) )

CosmicHorrorDev commented 1 year ago

Thanks for the follow-up!

It could be worth your time going ahead and filing an issue upstream. They'll be in a much better position to help

I think the best thing we can do downstream is to improve the error message to be more detailed

luukvanderduim commented 1 year ago

Can confirm, 10bit color depth is the problem. I will share it with them.

CosmicHorrorDev commented 1 year ago

Thanks for helping work through the issue! This would have been impossible for me to figure out on my own

luukvanderduim commented 1 year ago

No problem, thanks for making cool tools!