dmadisetti / steam-tui

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

Scroll lag on key hold #32

Closed mbpowers closed 2 years ago

mbpowers commented 3 years ago

When you hold j/k/up/down there is lag and will continue scrolling for a bit after the key is released. The lag doesn't become noticeable until I scroll more than about 10 items, but since I have a fairly large library cluttered with unplayed games from humble bundle this is frequent. If the scrolling lag is not an easy fix, a good work around would be to be able to filter the list to downloaded only.

Love the ascii art and vim binds, very cool program.

dmadisetti commented 3 years ago

Thanks 🎉 !

Hm, I haven't really noticed this. Is it for rapid pressing or when you hold down? There do definitely need to be more filters (DLCs, demos, other than games; see #11) You can search, but that doesn't address the issue. I have 2 theories:

  1. When you hit a new game, theres a blocking call to get an image if one does not exist (only the first time though). That could be the slow down, but should be better once you have scrolled the library. Changing the image to ANSI is also blocking.
  2. Since there's no debouncing in place, the event is triggered multiple times causing issues.

It might be both lol.

To address 1. we'd need background downloads (which actually couples with the proposed async implementation of #29), and/or ANSI caching. I think this is going to be a change to the widget itself. The original author is unresponsive, so we're working off this fork: https://github.com/AnotherGroupChat/tui-image/tree/rgba

To address 2 we need some debouncing logic, which I think is straightforward? Something I've never had to implement, but would probably require a change to the event handling: https://github.com/dmadisetti/steam-tui/blob/e48c25243e546d985cf8e9cb8d5f3f005f1bb674/src/util/event.rs#L40

anyway, I don't expect anyone to fix this, just suggesting solutions to the ether. When/if I do start working on this program again, I think this, #29, and #8 will be noticable speed improvements.

mbpowers commented 3 years ago

It's only when you hold it down.

Never touched rust but as it's so popular I figured I should dip my toes in, and this seems like a good project to join in on the fun. I might try and take a stab at some of these but don't wanna get your hopes up in case I fail or don't have time haha.

Also not getting the auto-downloaded icons ¯\(ツ)/¯

mbpowers commented 3 years ago

Figured out why I'm not getting the images its cause I pulled the steam-tui instead of steam-tui-git from AUR. false alarm!

dmadisetti commented 3 years ago

Yeah, I think rust is fun. If it's only on hold down, then # 2 (debouncing) is likely the issue.

So there are 2 event types, one is a timed event (we want the main loop to run every so often to communicate with the client thread), the other is an event loop (we want to respond to a user push). So debouncing means that we should not stack events, but wait an interval before the one next event queues. I think? There's probably better explanations online (all my quick Googling points me at JavaScript examples though). Good luck! Let me know if you run into any problems, and checkout Some basic rust documentation first: https://learnxinyminutes.com/docs/rust/

Rust is weird at first, but pretty powerful once you understand its quirks

dmadisetti commented 2 years ago

Yeah I see it. It overshoots and i slow to take off. Managing the event queue is the right way to do this.