bsmg / ModAssistant

Simple Beat Saber Mod Installer
MIT License
2.48k stars 419 forks source link

Race condition when checking for versions #474

Open Emosewaj opened 2 years ago

Emosewaj commented 2 years ago

When clicking the I Agree button after launching ModAssistant, I would always immediately get the error Could not download versions list. After doing regular troubleshooting with no success I've decided to dig into the code.

I was able to figure out that, at least on my end, the download of the resources at https://versions.beatmods.com/versions.json and at https://alias.beatmods.com/aliases.json both take exactly 42.5~ seconds each, meaning the game version check only happens after about a minute and a half, only after that does the I Agree button function properly, meaning checking for a checked version in the Main Window can potentially happen way before the version check has finished.

devenv_2022-09-07_00-25-36 devenv_2022-09-07_00-26-40

System.Diagnostics.Stopwatch was used to generate these timings. Note that both resources load instantaneously on my regular web browser. Only Mod Assistant is slow in acquiring them.

I would personally suggest that the check that causes the Could not download versions list error be decoupled from the I Agree button as the Mods tab button enables itself automatically once the version check has passed. The error popup may instead be tied to an actual failure during the download and/or check process. You could display a modal indicating that the version check is still in progress, perhaps like so: ModAssistant_2022-09-07_00-40-30 If the version check is still in progress after clicking I Agree, you could replace the text on the Intro tab with a hint that version check is still in progress, and to please wait.