Croptopia

Croptopia

30M Downloads

Huge lag and ram usage sometimes when saplings grow into trees

VeggeieDude opened this issue Β· 21 comments

commented

Make sure you are not opening a duplicate.

Platform.

Fabric

Minecraft version.

1.17.1

Croptopia version.

1.7.0

What happened?

Whenever a sapling from croptopia grows into a tree, sometimes it will cause huge lag and I basically have to shut the server down

Relevant log.

No response

Additional information.

No response

commented

There must be something else going on here because tree generation didn't change between 1.6.3 and 1.7.0.

If you could provide some evidence that it's croptopia doing this I'd love to see it

commented

Well the only trees that do this are from Croptopia. It could be another mod interfering with it or something, not sure. Can't get a crash log either because the world doesn't crash, just gets locked and gotta shut the game down.

The only thing I could think of is the world gen datapack I'm using (strider's redux II) but even then none of the other trees do this

commented

I am gonna try it without the snowy mod too, the one that makes every biome cold and have snow. Maybe there's a problem with the two together, all I can think of besides the world gen datapack lol. I'll let you know if it fixes it or not, thank you for the quick response!

commented

Can confirm I am experiencing the same issues. Been poking around the code, and can only think that it must be some sort of mod incompatibility. Can't confirm if letting the saplings grow naturally causes this, but bonemealing absolutely does, more often than not. But not every time.

commented

Also of note, this issue occurred for me on 1.6.2, so I kept upgrading until I am now on a freshly compiled version of 1.7.2 for 1.17.1, and it occurs on every version I tested. So something definitely seems to be happening on Croptopia's end, but no clue as to whether the actual fix will be with this mod or whatever else might be causing problems. Worth noting, I have other mods like Traverse and Better End that add many other types of trees, and the only trees causing this issue are the Croptopia ones. But after a lot of code scrolling, I don't see any significant difference with how you manage your trees versus Traverse.

commented

Sorry to blow you up on this, but it's rather game breaking for anyone wanting to grow a lot of these crops in survival, and I'm trying to figure out what's going on and potentially send you a PR xD

Cinnamon trees no longer exhibit this behavior, after me switching line 343 of GeneratorRegistry to a SimpleBlockStateProvider for the leaves (no need for the WeightedBlockStateProvider there, since there's only one kind of leaf). Which leads me to believe this has something to do with the fact that Cinnamon trees use the SimpleBlockStateProvider for leaves while I've left all other trees with the WeightedBlockStateProvider. Will do more testing to confirm.

EDIT: nevermind. That was not the culprit. :/

commented

I've gone through to try and replicate this again and I just can't seem to do it.

I've tried planting a ton of croptopia trees on top of a mountain and a ton of vanilla trees on top of the same mountain, afterwards the croptopia tree world had about ~100MB higher peaks looking at F3.

After closing the worlds and the game, and then going back into the worlds, without doing anything, it seems that the one planted with croptopia trees had a higher usage as well. which isn't even helpful because if I load into the world and do nothing, where is the extra RAM usage coming from?

Maybe what you are seeing is you're already near your RAM allocation and the croptopia tree is just enough to put it at 100%? I'm not sure.

Some questions:
What distribution of java do you use? (might have an effect?)
How many trees are we talking about planting (I planted probably around 75)
Is your ram usage already near max capacity when planting your trees?

When I originally tested this I ran the vanilla server and planted a bunch of trees and never saw the graph create spikes when I bonemeal grew them.

commented

Here is all I've I've found out:

Platform: Fabric
Minecraft: 1.17.1
Croptopia Versions: 1.6.2 - 1.7.2
Java Version: 17 LTS

Bug is almost certainly a bad mod interaction, as it is not reproducible on a server which only has this mod installed.

Bug is very specifically in regards to Croptopia trees growing from saplings, and does not seem to affect the Cinnamon tree at all, after doing more testing, both before and after my code modification mentioned above. This issue does not occur with any other trees, whether vanilla or modded.

To reproduce, I plant a Croptopia sapling and bonemeal until it is supposed to grow. Once it is supposed to grow, there are 3 possible outcomes:

  1. Server immediately hangs and is unresponsive to all console commands. Sapling never disappears, tree does not grow. On client, I can no longer place blocks, mob ai ceases to function, etc. The server goes into an endless tick which eventually "crashes" the server by triggering Minecraft's built-in server tick check, whereby Minecraft Server jar terminates itself when the time between two ticks is greater than a certain number of seconds. This is the most likely outcome.

  2. Sapling disappears and tree begins to form. Usually just one wooden block forms, but for sure, the leaves never start to form. At this point, server hangs and is identical to behavior described above in 1.

  3. Tree grows as normal. No RAM spikes or server hangs. This is exceptionally rare.

The very specific behavior seems to indicate a variety of things:

  1. Bad mod interaction -- the server does not hang when I am not running 368 other mods.

  2. There is some difference between how you are either creating or registering your saplings, generators or leaves compared to other mods that creates the issue specifically and only for Croptopia. Whatever the other mod is in this interaction is likely the true culprit, but there is almost certainly something that can be done differently here to prevent the interaction as well, and I frankly don't have time to reboot and retest Croptopia with 368 other mods. 🀣 So this is the approach to fixing that I have been taking (forked your code and have been looking through it, comparing to other mods with unaffected saplings / trees like Outvoted, Traverse, Promenade, and Woods and Mires).

  3. The server hang with no crash log and no errors would seem to indicate a bad for or while loop somewhere -- whether that would be something in this mod or whatever the other mod is causing this compatibility issue, I don't yet know. (On a side note, did you mean jsonElement on line 77 instead of just json? This is not a potential fix, already tried it and see no real difference regardless of which variable I use, but the way it's in that for loop seems to indicate jsonElement should be there rather than just json).

  4. Whatever is causing this, doesn't seem to mind generating the trees during chunk generation, only when bonemealing a sapling.

commented

Also, to answer your only unanswered question, my RAM usage is only about half utilized until the server hang occurs. Then it shoots up to near 100% and stays there until the Minecraft Server jar unceremoniously kills itself after a tick takes more than 60 seconds.

commented

yea that jsonElement bit is most likely a bug.

Ok, that's some good info. if it's happening not on chunk generation and only on sapling bonemealing. I would guess that there could be a mod that is using mixins in SaplingBlock, or possibly the abstract SaplingGenerator class

maybe try adding -Dmixin.debug=true as a startup property and check the log file/send it here. I would expect to see a SaplingBlock or SaplingGenerator mixin.

commented

Will do, give me an hour or so, got other projects I'm in the middle of. ☺️

commented

It's kind of insane how many of these mods don't pass the mixin debug. That said, I have yet to see anything sapling related with any of the mixins.. We may be at an impass, a version of LibCD is failing and it could be any version packaged in a LOT of these mods.

I do see a BoneMealMixin class in Croptosis, might go look at what's going on there.

Here's the log before the LibCD crash.
latest.log

EDIT: I don't see anything in the Croptosis BoneMealMixin that would cause this. Also checked TreeFeatureMixin from The Graveyard and don't see it causing this problem either.

commented

I've started just removing chunks of mods to rule out. I really didn't want to do this, but at this point, it's probably going to be the quickest (albeit most painful) way, unfortunately...

It's not Apple Trees Revived, BC Lib, Better End, Krypton, Immersive Portals, Repurposed Structures, The Graveyard, Croptosis or Waystones. Which realistically leaves these:

- [email protected]
- [email protected]+1.17.1
- [email protected]
- [email protected]
- [email protected]+mc.1.17
- [email protected]+mc21w16a
- [email protected]
- [email protected]+1.17.1
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]+fabric
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]+1.17
- [email protected]+1.17.1
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]+1.17
- [email protected]+1.17.1
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- com_eliotlash_mclib_mclib@18
- com_eliotlash_molang_molang@18
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]+4.1.1
- [email protected]+1.17
- [email protected]+1.17
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]+1.17
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]+1.17
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]+1.17.1
- [email protected]+1.17.1
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]+j1.2.0
- java@17
- javax_inject_javax_inject@1
- [email protected]
- [email protected]
- [email protected]
- [email protected]+1.17
- [email protected]
- [email protected]+1.16.3
- [email protected]+1.17.1
- [email protected]
- [email protected]
- [email protected]+1.17
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]+1.17.1
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]+1.17
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]+1.17
- [email protected]+1.17
- [email protected]+1.17
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]+fabric
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]+fabric.73f6d37
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]+1.17
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected]+1.17
- [email protected]
- [email protected]
- [email protected]

I'll let you know when I finally strike gold lol....

commented

damn, yea, that's a lot of mods

commented

luckily i managed to find this problem here. I had the same issue... I had to disable the Mod Straw Golem to solve the problem. Unfortunately... i hope soon we could have a fix to this :/

commented

It's Straw Golem. Most likely this mixin, lines 23 - 29.

commented

yup, dang that's fast

commented

only took me going through the majority of the mods first. xD

commented

Gonna try adding the Croptopia "tree crops" to their blacklist and see if that works. If not I'll probably try and fork their code and send them a PR.

commented

looks like that chain of methods would be the culprit

image

commented

Putting the following into their config's blacklist works as a stopgap solution, but there is probably a better one in code that would prevent users from needing to modify Straw Golem config out of the box. Would assume this is something they will need to fix.

blacklist = [croptopia:apple_crop,croptopia:banana_crop,croptopia:orange_crop,croptopia:persimmon_crop,croptopia:plum_crop,croptopia:cherry_crop,croptopia:lemon_crop,croptopia:grapefruit_crop,croptopia:kumquat_crop,croptopia:peach_crop,croptopia:coconut_crop,croptopia:nutmeg_crop,croptopia:fig_crop,croptopia:nectarine_crop,croptopia:mango_crop,croptopia:dragonfruit_crop,croptopia:starfruit_crop,croptopia:avocado_crop,croptopia:apricot_crop,croptopia:pear_crop,croptopia:lime_crop,croptopia:date_crop,croptopia:almond_crop,croptopia:cashew_crop,croptopia:pecan_crop,croptopia:walnut_crop]