dev7355608 / vision-5e

Foundry VTT Module: Vision/Detection Modes for D&D 5e
https://foundryvtt.com/packages/vision-5e
MIT License
13 stars 11 forks source link

Build JS files into a bundle to reduce requests #41

Open 346184 opened 1 year ago

346184 commented 1 year ago

Hey! While debugging the large number of requests causing infrastructure issues when loading into Foundry, I saw that the module currently needs 47 requests for me on each load into Foundry:

47 vision-5e
# 1 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/style.css
# 2 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/patches.js
# 3 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/automation.mjs
# 4 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/compatibility.mjs
# 5 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/config.mjs
# 6 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/hud.mjs
# 7 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/settings.mjs
# 8 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/detection-modes/blindsense.mjs
# 9 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/detection-modes/blindsight.mjs
# 10 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/detection-modes/darkvision.mjs
# 11 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/detection-modes/detect-evil-and-good.mjs
# 12 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/detection-modes/detect-magic.mjs
# 13 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/detection-modes/detect-poison-and-disease.mjs
# 14 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/detection-modes/detect-thoughts.mjs
# 15 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/detection-modes/devils-sight.mjs
# 16 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/detection-modes/divine-sense.mjs
# 17 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/detection-modes/echolocation.mjs
# 18 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/detection-modes/ethereral-sight.mjs
# 19 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/detection-modes/ghostly-gaze.mjs
# 20 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/detection-modes/hearing.mjs
# 21 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/detection-modes/light-perception.mjs
# 22 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/detection-modes/see-invisibility.mjs
# 23 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/detection-modes/tremorsense.mjs
# 24 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/detection-modes/truesight.mjs
# 25 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/detection-modes/witch-sight.mjs
# 26 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/vision-modes/blindsight.mjs
# 27 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/vision-modes/darkvision.mjs
# 28 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/vision-modes/detect-evil-and-good.mjs
# 29 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/vision-modes/detect-magic.mjs
# 30 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/vision-modes/detect-poison-and-disease.mjs
# 31 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/vision-modes/detect-thoughts.mjs
# 32 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/vision-modes/devils-sight.mjs
# 33 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/vision-modes/divine-sense.mjs
# 34 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/vision-modes/echolocation.mjs
# 35 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/vision-modes/ghostly-gaze.mjs
# 36 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/vision-modes/tremorsense.mjs
# 37 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/vision-modes/truesight.mjs
# 38 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/detection-modes/filters/ping.mjs
# 39 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/detection-modes/detect.mjs
# 40 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/vision-modes/shaders/detect.mjs
# 41 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/vision-modes/shaders/tremor.mjs
# 42 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/scripts/vision-modes/shaders/void.mjs
# 43 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/lang/de.json
# 44 -> https://assets.forge-vtt.com/bazaar/modules/vision-5e/1.10.1/lang/en.json
# 45 -> modules/vision-5e/icons/burrow.svg
# 46 -> modules/vision-5e/icons/inaudible.svg
# 47 -> modules/vision-5e/icons/ethereal.svg

Would be nice if you could bundle the JS files with a build step when distributing, so they are not all separate HTTP requests. If everyone does this, even 10 modules require 470 HTTP requests, and some people tend to have way more modules.

Thanks for the amazing module. :)

LukasPrism commented 1 year ago

Sorry to butt in, I'm just curious what these infrastructure issues you're referring to are?

I currently have 1745 requests to load into FVTT... 345 come from one module so V5E seems very tame by comparison. I haven't noticed any issues myself, although one of our players does have trouble getting in sometimes and it can take a few minutes (takes me 11 seconds). Have tested his fibre and it's not a bandwidth issue.

If there really is an issue with too many requests, I wonder if it's something core could look at – bundling module JS into one request? Probably a good one for Eber to weigh in on...

346184 commented 1 year ago

Sorry to butt in, I'm just curious what these infrastructure issues you're referring to are?

In general, if you aren't hosting locally, hosting providers frown on anything making thousands of simultaneous requests. It triggers security measures, it costs a lot of resources and yeah, it adds to loading times, because even with the magic that is the modern internet, each request adds a bit of latency and loading time, even with HTTP/2 pipelining.

Concretely, this issue seems to currently contribute to a outage suffered by some Forge users, because something in these Foundry request patterns seems to trigger something on the side of the Cloudflare CDN, where Forge hosts assets like modules.

We're* in contact with Cloudflare to fix that, but at the same time expecting 1745 simultaneous requests to just go through is asking for trouble anywhere. Imagine all your 4 players load in at roughly the same time with you, thats nearly 10.000 requests in the span of seconds. People were booted off their cheapo ISP or hosting for less intense workloads :)

So I thought I'd try to contact the modules making the most requests in my world and ask nicely if they could think about optimizing a bit (if they are not abandoned, and if it is possible - for example, some modules just need to load tons of assets by their nature, or translation modules need one JSON file per system compendium, sadly).

* We, as in the affected users; I'm not part of Forge or anything or speaking for them, just one of the affected people :)

345 come from one module so V5E seems very tame by comparison

Yikes, 300+ is crazy. TokenMagic takes 80-90, and I've had to disable that for now. Dice so Nice likewise takes 50-60. Those are the big outliers in my module heavy world.

Most modules seem to take around 2-6 requests (mostly 1 JS, 1 lang file, 1 CSS file, maybe some icon). Some take 10-20. I've decided to start messaging any of the ones that are not abandoned and that seem easy-ish to improve (for example, by bundling the JS files).