Intercepted asset loading always misses cache in languages other than English
danvolchek opened this issue ยท 1 comments
Summary
When SDV tries to load an asset intercepted by SMAPI and the language is set to English the request misses the cache once and then hits it for all future attempts (as expected).
However, if the game language is anything but English those loads miss the cache every time and trigger a full load. This causes lag if it happens frequently and the file needs to be read from disk.
Minimal Example
using StardewModdingAPI;
using StardewValley;
public class BugReproMod : Mod, IAssetLoader
{
public override void Entry(IModHelper helper)
{
this.Helper.Events.GameLoop.UpdateTicked += this.GameLoop_UpdateTicked;
}
private void GameLoop_UpdateTicked(object sender, StardewModdingAPI.Events.UpdateTickedEventArgs e)
{
if(e.IsOneSecond)
{
Game1.content.Load<string>("bug-repro-test");
}
}
public bool CanLoad<T>(IAssetInfo asset)
{
return asset.AssetNameEquals("bug-repro-test");
}
public T Load<T>(IAssetInfo asset)
{
return (T) (object) "";
}
}
Download:
BugRepro.zip
Set the game language to English and Bug Repro loaded asset 'bug-repro-test'
is seen only once. Set the language to anything else and you see that line every second.
Real World Example
This log showcases the issue: https://log.smapi.io/eGqrQZ0z. Girl Mod is a Content Patcher pack that loads LooseSprites/Cursors
and the language is set to Chinese. Every time the game requests that asset, it reloads it from an XNB file, causing the user to experience very noticeable lag.