Entity renderer setup re-opens resource packs countless times, leading to absurd game load times when combined with conditional dynamic resource generation
lukebemish opened this issue ยท 3 comments
Forge Version
47.1.3
Twilight Forest Version
4.3.1850
Client Log
https://gist.github.com/lukebemish/ee4cd5d4730c7452d6e51a429f4f5d55
Crash Report (if applicable)
No response
Steps to Reproduce
- Install Exavated Variants, Dynamic Asset Generator, and Twilight Forest. Adding more mods that provide resources, or that Excavated Variants will generate variants for, will increase the effect.
- Launch the game
What You Expected
This bug was encountered while investigating lukebemishprojects/ExcavatedVariants#174. What occurs is that
is used countless times during load - each load invokesPack#open
and PackResources#getResource
for each Pack
in the pack repository. This operation is made expensive when a mod - in this case, the combination of Excavated Variants and Dynamic Asset Generator - makes this operation expensive for some packs. The resources that DynAssetGen generates depend on the contents of certain other resources in other packs - meaning that DynAssetGen has to re-load, read, and process those resources each time this method in Twilight Forest is invoked. This leads to an extremely long load time - in the case of the issue I was investigating, it appeared to cause the game to crash in some way. There is not really any way around this in DynAssetGen - I have to recalculate that stuff each time it's opened because there's no guarantee that the resources it depends on haven't changed between resource reloads - say, if a resource pack is changed by the user.
What Happened Instead
Load time took around 5 minutes to set up twilight forest entity renderers with a larger pack, where Excavated Variants has a larger number of things to check on during resource reload: https://gist.github.com/lukebemish/c21c899b10fab7c48f8b0e5d4081605a
Additional Details
In my opinion, the optimal solution here would be for Twilight Forest to query the PackResources
of the currently open ResourceManager
directly - with Minecraft.getResourceManager().listPacks()
. Is there a reason this would not work? It uses the already open pack instances, instead of re-opening every single pack every time the listener or that supplier is used - which is what the current solution does.
Please Read and Confirm The Following
- I have confirmed this bug can be replicated without the use of Optifine.
- I have confirmed the details provided in this report are concise as possible and does not contained vague information (ie. Versions are properly recorded, answers to questions are clear).
- I have confirmed this issue is unique and has not been reported already.
Heyo! Very sorry about that. I wasnt aware listPacks was a thing: switched to it and everything still seems to still be working as intended. Can you give this build a test and see if it fixes the issue?
I tested before pushing, models are still changed as needed. Thanks for letting me know about this! I'll have a fix pushed onto curseforge after I fix another issue I need to tackle