Slluxx / IconGrabber

GNU General Public License v3.0
30 stars 8 forks source link

Multi-thread or preload images #8

Open rlaphoenix opened 1 year ago

rlaphoenix commented 1 year ago

It's extremely slow to scroll through the list of images because it downloads quite slowly, as you scroll. It would be a lot better if it downloaded multiple images at a time and sort of "preloaded" them.

Ideally, when you first click on a search result it preloads the first image like it currently does. But have it automatically preload the next image in the list and when that is preloaded, preload the one next on the list and repeat until the user exits the menu.

I imagine it's not currently working this way because you need to store the downloaded image somewhere. But you already have an image cache storage system in place, but instead use it more akin to a downloads folder which I personally believe to be an invalid way of using that. You could just make a temp directory and store them in there, then clear it when you exit the menu and then clear it on startup in case of an abrupt shutdown of the homebrew.

Slluxx commented 1 year ago

+1 Preloading is planned and somewhat implemented in the new branch already. The problem is that i cant leave images in RAM, which is possible but would cause a fatal error once the usable ram is filled. My intention was to download low res preview images that load faster and store them on disk, so everything would smooth out over time but i messed up some things when i wrote it first and didn't know enough about c++.

Another problem is that threads are horrible in c++. Every thread has to be started and stopped from the main thread and handling data between them / acknowledging data from side to main thread and using it is not fun. I have some ideas how to deal with that stuff, using atomic values and not using mutexes but if possible, id like to avoid that.

Anyway, multithreading is being worked on.