Open Cervator opened 5 years ago
Looks like a recursive Asset/Prefab dependency (A component in prefab A refers to prefab B, and a component in prefab B refers to prefab A, or a longer loop). We could either modify the asset to remove the recursion, or we could add lazy or late loading of prefabs where we resolve the prefab using an Asset.get
call only after all prefabs have been loaded.
Hit it by chance again and reminded myself that the affected asset seems pretty clear even based on the log snippet above: easterEgg.prefab
in ShatteredPlanes refers to itself as a StructureTemplate, which is kinda weird as it doesn't actually depend on the ST module. I think that the error only happens if the ST module is also enabled, as otherwise that part of the prefab just gets ignored (as the game doesn't know what an ST is if its module isn't enabled)
It would be nice to find a way to harden the engine to simply log a warning for a circular reference rather than crash. Although at least it crashes on startup not at some arbitrary point later in a game session.
To replicate: Define an asset that ends up referring to itself. Example easterEgg.prefab
in ShatteredPlanes (adjust naming as needed for a different example):
{
"StructureTemplate": {
"type": "ShatteredPlanes:easterEgg"
}
}
What you were trying to do
(Edit: Updated way later with more details)
Put together a complex set of modules for play testing. Eventually figured out there was a circular reference in
easterEgg.prefab
in ShatteredPlanes but it would only trigger if you also had StructureTemplates enabled. Fixed with https://github.com/Terasology/ShatteredPlanes/pull/8We should hopefully be able to catch and guard against such circular references at the engine level, bypassing the load of invalid prefabs and logging the issue clearly.
What actually happened
Crashed during initial world loading with a stackoverflow as the
easterEgg.prefab
was being processed, and effectively had a reference to itself.How to reproduce
See this further down https://github.com/MovingBlocks/Terasology/issues/3739#issuecomment-608162476
Log details and game version
Latest develop with all modules at latest as of writing this
Note the first set of lines repeat quite a few times, and the stacktrace of course also keeps going for a while before the crash.