Closed WalshyDev closed 6 months ago
Your Pull Request was automatically labelled as: "✨ Fix" Thank you for contributing to this project! ❤️
Issues
12 New issues
Measures
0 Security Hotspots
66.7% Coverage on New Code
0.0% Duplication on New Code
A Slimefun preview build is available for testing! Commit: 99c7411b
https://preview-builds.walshy.dev/download/Slimefun/4127/99c7411b
Note: This is not a supported build and is only here for the purposes of testing. Do not run this on a live server and do not report bugs anywhere but this PR!
Description
Fixes exhaustion when loading large PlayerProfiles due to multiple load calls being made. If we're already loading the profile, we don't want to spin up a whole new thread and load the profile again/more. This can very easily cause CPU, memory and thread exhaustion if the profile is large
We saw AbstractArmorTask constantly try to get the PlayerProfile (every 10 mc ticks) even though the profile was still being loaded (due to it's very large size). This compounded the issue and ended up killing servers off entirely.
Proposed changes
Add tracking for when we're loading the PlayerProfile from file into memory. If the profile is loading, we will simply return and not try to load it again. This does mean that callbacks for PlayerProfile#get are currently tossed away, this isn't ideal but IMO is acceptable here. It will just mean if someone interacts with a block/item quickly and they have a large profile, instead of the interaction happening after load it will just not happen and they will need to re-interact. This is only for first load so not a big deal but worth calling out.
Related Issues (if applicable)
Fixes #4011 Fixes #4116
Checklist
Nonnull
andNullable
annotations to my methods to indicate their behaviour for null values