dmadisetti / steam-tui

Rust TUI client for steamcmd
MIT License
848 stars 17 forks source link

Blank Menu After Login - Crashes on Navigation Attempt #59

Closed makusu720 closed 1 year ago

makusu720 commented 1 year ago

After successfully opening the TUI and logging into my Steam account, I am presented with a blank menu where I'd expect to see my list of games. I've tried re-logging into Steam but the problem persists. Furthermore, when I attempt to navigate the blank menu, the app crashes. image The application doesn't display any error messages in stderr until I try to navigate. The app was launched with RUST_BACKTRACE=full.

thread 'main' panicked at 'Index is guarded by next, previous. This is safe.', /build/source/src/util/stateful.rs:39:22
stack backtrace:
   0:     0x561a98cd166a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h248962d2d122e2c9
   1:     0x561a98cf9d2f - core::fmt::write::h5f95cb8cfa6115f7
   2:     0x561a98cdd8e5 - std::io::Write::write_fmt::h84b7654c24157227
   3:     0x561a98cd1425 - std::sys_common::backtrace::print::h2e5be404ab22c93f
   4:     0x561a98cd6cfe - std::panicking::default_hook::{{closure}}::h098fd3ade5bcfd5b
   5:     0x561a98cd69b9 - std::panicking::default_hook::h01e9e78d073c3fbc
   6:     0x561a98cd7251 - std::panicking::rust_panic_with_hook::h110f1ac29bb0350d
   7:     0x561a98cd1999 - std::panicking::begin_panic_handler::{{closure}}::h5045ea681cf020a4
   8:     0x561a98cd1776 - std::sys_common::backtrace::__rust_end_short_backtrace::h5a41a5e5cb43f3f7
   9:     0x561a98cd6f52 - rust_begin_unwind
  10:     0x561a98b4d323 - core::panicking::panic_fmt::hb69349353d008f71
  11:     0x561a98b4d1d3 - core::option::expect_failed::h29f70ad0483bd034
  12:     0x561a98b4f33c - steam_tui::util::stateful::StatefulList<T>::selected::hef86a634f531f434
  13:     0x561a98b517f4 - steam_tui::main::h06e5cea6220eec52
  14:     0x561a98b4f5a3 - std::sys_common::backtrace::__rust_begin_short_backtrace::h42a0ff66b3733c8c
  15:     0x561a98b4f5b9 - std::rt::lang_start::{{closure}}::h9799b639b6920e92
  16:     0x561a98cd6e51 - std::panicking::try::he791fc1a94a09c44
  17:     0x561a98cbdfdb - std::rt::lang_start_internal::h0972b5621afa304e
  18:     0x561a98b52485 - main
  19:     0x7f9379a1bace - __libc_start_call_main
  20:     0x7f9379a1bb89 - __libc_start_main@@GLIBC_2.34
  21:     0x561a98b4d765 - _start
  22:                0x0 - <unknown>

OS: NixOS unstable

makusu720 commented 1 year ago

I think I found the problem. When I try to run install_folder_list in steamcmd I get:

Command not found: install_folder_list
dmadisetti commented 1 year ago

Hmm, thanks for looking into this. What version of steamcmd/steam-tui are you using?

makusu720 commented 1 year ago

I use the NixOS package, steam-tui says 0.1.0 and steamcmd says 20180104, maybe that is the problem. I looked again install_folder_list is described in the documentation but library_folder_list is correct. That returns this:

Steam>library_folder_list
Index 0, ContentID 730839655393167317, Path "/home/makusu/.local/share/Steam", Label "", Disk Space 290.54 GB/472.46 GB, Apps 1, Mounted yes
Index 1, ContentID 4920503852786898767, Path "/mnt/ssd/SteamLibrary", Label "", Disk Space 319.72 GB/1,862.17 GB, Apps 83, Mounted yes
statvfs64: ret -1 errno 2
  f_bsize : 0
  f_frsize: 0
  f_blocks: 0
  f_bfree : 0
  f_bavail: 0
src/tier1/fileio.cpp (3931) : Assertion Failed: statvfs64 failed for /mnt/GameVault/steam.temp, errno 2
Execute: /home/makusu/.local/share/Steam/ubuntu12_64/disk-free /mnt/GameVault/steam.temp >/tmp/disk-free.I8123W
src/tier1/fileio.cpp (3962) : disk-free command failed

Index 2, ContentID 1295556351605306617, Path "/mnt/GameVault/steam.temp", Label "", Disk Space 0 bytes/0 bytes, Apps 1, Mounted no
Index 3, ContentID 1295556351605306617, Path "/mnt/GameVault/SteamLibrary", Label "", Disk Space 559.40 GB/3,998.83 GB, Apps 5, Mounted yes

/mnt/GameVault/ is a NFSv2 mount

dmadisetti commented 1 year ago

I don't think install_folder_list or library_folder_list is part of the logic flow from what I remember:

https://github.com/dmadisetti/steam-tui/blob/main/src/client.rs#L475-L481 The error might have to do more with the non-standard steam location.

To debug you can do steam-tui 2> my.log, but I am unsure whether this made it into the nixos version cut

makusu720 commented 1 year ago

I have now cloned the repo and tried it with the flake.nix, also without success. Nothing is printed in the stderr. The only debug message I get is when I navigate in the empty menu.

thread 'main' panicked at 'Index is guarded by next, previous. This is safe.', /build/source/src/util/stateful.rs:39:22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I think this error is caused by the fact that I want to navigate outside of the scope or it doesnt find a value because there are no games loaded.

If I understand your code correctly you start with a licenses_print call and then call each entry with package_info_print and app_info_print. I can reproduce this in steamcmd but after calling app_info_print it doesnt return to the input but the cursor keeps flashing,I dont know if this is normal.

The comment mentions that it puts the game objects in a games.json file, this file only exists on my pc in ~/.config/steam-tui not in ~/.cache/steam-tui and contains an empty array.

I also tried to change the STEAM_APP_DIR enviroment variable without success.

dmadisetti commented 1 year ago

Panic is due to empty list. So much for "this is safe" lol.

app_info_print <app id> should give you a very long detailed description of a given app (listed under appids of a package_info_print <package id)`. I think the issue might lay here.

Try nix develop (maybe comment out the lutris and out cruft deps first), and use that steamcmd.

The comment mentions that it puts the game objects in a games.json file, this file only exists on my pc in ~/.config/steam-tui not in ~/.cache/steam-tui and contains an empty array.

I think that's a version difference- running from source should give you the right location. But delete those files anyway (or press i think R?) since we won't reload if the games have already been cached.

makusu720 commented 1 year ago

app_info_print and package_info_print both work as expected. The only strange behavior is that app_info_print doesnt return to the input: image I need to hit enter, than I'm back in the input: image

Now with running from source (nix develop), it still creates the empty games.json. I also tried to press R, it refreshed but doesnt change anything.

makusu720 commented 1 year ago

I think your assumption that it has something to do with my Steam installatation could be right. I tried to install steam-tui and steamcmd this morning using distrobox and had the same problem with the empty menu.

What I noticed in your code is that in this line https://github.com/dmadisetti/steam-tui/blob/main/src/interface/game.rs#L105 there is a stderr if the game object could not be created, since I do not get this I assume that it is never called.

Another guess could be that there is a problem with the parsing, I have attached the output of the licensed_print. licenses_print.txt

makusu720 commented 1 year ago

I have now tried another Steam account that has fewer games. The login and the load works much faster with this one, but still nothing is displayed in the menu at the end. I have a feeling that the problem is really related to the fact that it doesn't write anything to the games.json file.

makusu720 commented 1 year ago

I managed to intercept the output of steam-tui and it's subprocesses while loading using strace -f -o /tmp/strace_new -s9999 -e trace=write steam-tui. I have attached a quick parsed file, it all looks right to me. Which again reinforces my suspicion that there is a problem saving the game objects but not fetching it. strace_new_parsed.txt

dmadisetti commented 1 year ago

Parsing your license stuff was fine.

I blew away my cache and have the same thing happening. Something is wrong with the parsing, the game lookups are 1 behind the query. e.g.

parse 1 parse 2 parse 3 lookup 2 with data for 1 lookup 3 with data for 2

I think because of that hanging char you mentioned earlier in app_info_print

Draft (not working) branch at weird-59, run with 2> to get logs

Need to scrub past that hanging character

makusu720 commented 1 year ago

I can't login with the built binary via distrobox and cargo build --release, looks like the same problem as #54.

When I try to build it with nix build I get an error on the test:

error: builder for '/nix/store/y7ylixdyy03gsww3w0lfh4c0qvvjjgz0-steam-tui-dev.drv' failed with exit code 101;
       last 10 log lines:
       > thread 'client::tests::test_license_parse' panicked at 'Failed to unwrap', src/client.rs:647:9
       > note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
       >
       >
       > failures:
       >     client::tests::test_license_parse
       >
       > test result: FAILED. 7 passed; 1 failed; 0 ignored; 0 measured; 2 filtered out; finished in 0.00s
       >
       > error: test failed, to rerun pass '--lib'
       For full logs, run 'nix log /nix/store/y7ylixdyy03gsww3w0lfh4c0qvvjjgz0-steam-tui-dev.drv'.

I also tried to build a default.nix (need to disable tests) with rev weird-59 or 33e1c4a5422e046e58f6d944f566356cedca243a but on both builds stderr doesnt return anything.

makusu720 commented 1 year ago

nvm, the cargo build works I just can't log in but I can force it with a refresh. Login attempt: cargo_steam-tui.txt

Refresh: cargo_steam-tui_2.txt

dmadisetti commented 1 year ago
   > thread 'client::tests::test_license_parse' panicked at 'Failed to unwrap', src/client.rs:647:9
   > note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Yeah, this is left over from writing a test to validate your license dump, I just removed it.

dmadisetti commented 1 year ago

Yeah, you can see the same issue in dump 2 at line 1054. It's looking for ID 1826330 but the buffer is empty.

When it looks for the next game, the buffer contains the info for 1826330

dmadisetti commented 1 year ago

@makusu720 I think it works: https://github.com/dmadisetti/steam-tui/tree/weird-59

It's a little weird, and a little slow. Will clean up and merge to main after you confirm

makusu720 commented 1 year ago

Yeah, now it works, like you said still a little clunky but it works.

Brueggus commented 1 year ago

@dmadisetti I'm having the same issue - thanks for the fix! Could you possibly create a new release version and update the Arch package? Would be much appreciated!