NPBruce / valkyrie

Valkyrie GM for Fantasy Flight Board Games
Apache License 2.0
506 stars 105 forks source link

Enhancement: Caching and saving scenarios' images #1131

Open chrismaliszewski opened 5 years ago

chrismaliszewski commented 5 years ago

Originally posted by @BenRQ in https://github.com/NPBruce/valkyrie/issues/1128#issuecomment-476907721

Caching image on local disk is probably not a big priority, images are loaded after the list > is fully loaded and available. So you can navigate in it, already.

Agree that caching, is not a big problem and it can wait especially since images are loaded after the SE list is created what doesn't prevent a user from working. The only big(?) issue with caching is wasting a transfer for mobile.

Still, I'd urge to save the images on the client's side for faster work and saving data.

  1. After creating the list, SE checks if images are available locally.
  2. If no, it downloads a scenario's image and saves it.
  3. If yes, it uses the locally saved image.

Each scenario has only one image so everything will be fine. Images could be named after... scenario's version (without "-" symbols).

The only problem with the idea: the old images are left behind. Therefore, there could a method running in the background after SE is fully loaded which would delete the rest of images unused.

BenRQ commented 5 years ago

So it would not be only caching data, but also storing the picture permanently. We would need a mechanism to make sure the file has not been updated online. I know you can do this with HTTP headers for cache system, but it's not perfect in my opinion.

Now another point on this : it depends what is your priority : saving disk space, or saving mobile data ? I would say disk space, because I'm using WiFi, and my 4G is unlimited but it will depend on every country I guess.

I'm curious to know what you guys would prefer : taking disk space, or saving data?

chrismaliszewski commented 5 years ago

Just to be more precise:

taking disk space by saving images permanently on the user's machine, saving mobile data and speeding-up rendering of SE's images VS saving disk space and lazy loading SE's images which will be cached only temporary

BenRQ commented 5 years ago

I'm not sure it would take less time, as we would need to check on server side if the file is updated anyway. Or we can do this in parallel but it get overly complicated for just such a small optimization.

chrismaliszewski commented 5 years ago

Question: does changing a scenario's image modify its version in the https://drive.google.com/file/d/13JEtzRQ1LcCAAhKluxii0tgKDW71XODV/view kind of a file?

chrismaliszewski commented 5 years ago

Again, you're right. The change will not speed-up SE but the downloading/rendering the images.

So the question is the one you asked, which is: "Do you prefer saving mobile data and storing images on your machine or saving your storage space?" Let's way for others' opinions.

scrubbless commented 5 years ago

I personally think data is more of a commodity than disk space. We are talking about at present 30 x 50kb files. Assuming all the files are around the 200x200px mark, it's going to take hundreds of image files to consume even 1% of modern devices.

The added bonus to local load is that you'll always get a consistent experience when running the SE.

I've noticed that on the train or in poor 4g areas the SE seems sluggish and awkward. I assume this is the image download happening.

My point is, a menu like that should be smooth to the end user. If they then download a scenario and the loading bar is slow, they wont care since that's what a loading bar is for. If they open SE and its jumpy they'll assume it's bad coding.

redwolf2 commented 5 years ago

Cache it and only update the image, when the scenario version changes.