Aedif / TokenVariants

GNU General Public License v3.0
18 stars 12 forks source link

Cache on load should not happen for players / perf impact #64

Closed kinland closed 2 years ago

kinland commented 2 years ago

The first 30-60 seconds of having Foundry VTT open up, it's extremely sluggish due to Token Variant Art trying to do caching in the background.

It's one thing for this to happen for DMs... but this should NEVER happen at all for players! Players are extremely unlikely to ever need to use Token Variant Art in any capacity, and the few cases they might, they could just ask the DM to pick art for them.

Honestly, though, this behavior is pretty undesirable for DMs, too. My asset library rarely changes - why does it need to rescan unchanged files and cause sluggish performance every time I load Foundry VTT?

I've taken to simply disabling Token Variant Art when I am not actively using it, but this has its own set of annoyances (namely, having to load without it, turn it on, reload, use it a bit, turn it off, reload)

If nothing else, cache should be a low priority task so that it doesn't cause the UI to become nonresponsive. And yes, I know you can disable the cache, but that's a poor option, as well.

Aedif commented 2 years ago

Hi,

That's an extremely long waiting time, akin to what I've heard before from ForgeVTT users. If you're using ForgeVTT I'd recommend to make sure that you're using the 'Forge Asset Library Paths' setting to expose your Assets Library to the module instead of 'Search Paths'. It has some specific optimisations for ForgeVTT that should massively boost the caching speed.

Now regarding the players having to cache the images too. This should only happen if you have permissions setup in a way that means they may require access the module's search functionality. Enabling any of these features will cause the module to perform a cache operation for the player with that role on game load:

image

With the setup above your players and trusted players will still have access to the Token HUD button but will not require the image cache as that button will only contain shared and wildcard images.

If you're not a ForgeVTT user and the example permissions setup is not ideal for you, then I may need to look into optimizing the caching in some way.

Usually scanning even 10k+ images isn't an issue, I know some people have massive libraries but... I'd be curious to know just how many images is the module finding for you? 😄

Aedif commented 2 years ago

If the above doesn't work, as of release 2.1.0 there is now a 'Static Cache' setting which will store the current cache in a file, which will be read when the game is loaded instead of performing caching again.