CyclopsMC / IntegratedTerminals

Terminals for managing and overviewing Integrated Dynamics networks
MIT License
5 stars 6 forks source link

"Tried to read NBT tag that was too big" with large numbers of crafting recipes #99

Closed Mike-Baker closed 1 year ago

Mike-Baker commented 1 year ago

Issue type:


Short description:

NBT size error with large numbers of crafting recipes (~220 in my world but it will likely vary based on recipe size?)

Symptoms:

Mitigation:

Additional Errors: If you have one "overloaded" channel and one working channel, filtering the terminal to just the overloaded channel will show nothing, filtering it to the working channel will show the working recipes however filtering it to "all" will result in the results of the working channel endlessly cloned again and again and again

Diagnosis: With help from kirjorjos and Natalie in your discord we came to the tentative conclusion that the issue is that all the NBT data for a channel's crafting recipes is serialised into one CompoundTag NBT object which then fails serialisation? deserialisation? at some point. Regrettably I wasn't able to isolate where this happens in the code myself but I can provide more details, screenshots and/or a save file if that would help?

Steps to reproduce the problem:

  1. Create a large number of crafting interfaces, and fill them with a large number of recipes (~220)
  2. Try to open the storage terminal
  3. Observe no recipes present
  4. Remove some recpies/interfaces
  5. Remaining recipes re-appear in the terminal

Expected behaviour:

All recipes visible in storage terminal


Versions:

Log file:

https://pastebin.com/nK2gafAZ

rubensworks commented 1 year ago

@Mike-Baker Your issue appears to be not following one of the allowed issue templates, which breaks our automation tools. Please update your issue to the proper template.

rubensworks commented 1 year ago

In any case, the relevant part of the code is here: https://github.com/CyclopsMC/IntegratedTerminals/blob/5fbb4387929ff3d6f4ca0b479d8be721f94180d8/src/main/java/org/cyclops/integratedterminals/core/terminalstorage/TerminalStorageTabIngredientComponentServer.java#L334-L335

Could you try lowering terminalStoragePacketMaxInstances in your config file, to see if that resolves your problem? We may have to lowering that value by default. (or we may have to add a dedicated option for crafting instances specifically, since crafting and storage instances currently both make use of this option, while the former is significantly larger NBT-wise)

Mike-Baker commented 1 year ago

I have updated the issue text so it should conform to the right template now.

rubensworks commented 1 year ago

Thanks!

Mike-Baker commented 1 year ago

Dropping terminalStoragePacketMaxInstances from 1024 to 512 didn't help neither did 256, but dropping it to 128 seemed to fix the issue. (which makes sense given my network was blowing up at 220 recipes)

This does imply that the average recipe in my world takes around 10 kilobytes, I don't know if that's an abnormal case or if you could use it as a heuristic for finding the correct value.

rubensworks commented 1 year ago

Thanks for checking!

Will look into adding a separate config option then for crafting instances, with the default set to 128 or so.

Mike-Baker commented 1 year ago

Thanks for the super quick reply and fix 👍

I will leave this open in-case you want to use it to track the updated config, but otherwise I want to say that your code is very nicely structured and I have been really enjoying the integrated suite of mods!

rubensworks commented 1 year ago

Best to leave the issue open for now indeed.

Thanks for the kind words! :-)