64place
1 vote Vote

"Collection was modified" Exception - randomly occuring

Hi, we've been encountering an issue where the map generation will occasionally/randomly throw out an exception after calling mapMagic.StartGenerate().

The map is being generated at runtime, rather than edit time, using a dynamically created Mapmagic.Nodes.Graph object.

MapMagic version 2.1.12


I have included a callstack here:

System.Collections.Generic.Dictionary`2+ValueCollection+Enumerator[TKey,TValue].MoveNext () (at :0)
MapMagic.Products.TileData.Clear (System.Boolean clearApply, System.Boolean inSubs) (at C:/Project/Assets/3rd Party/MapMagic/Products/TileData.cs:638)
MapMagic.Terrains.TerrainTile.Generate (MapMagic.Nodes.Graph graph, MapMagic.Terrains.TerrainTile tile, MapMagic.Terrains.TerrainTile+DetailLevel det, MapMagic.Products.StopToken stop) (at C:/Project/Assets/3rd Party/MapMagic/Terrains/TerrainTile.cs:732)
MapMagic.Terrains.TerrainTile+c__DisplayClass50_1.b__0 () (at C:/Project/Assets/3rd Party/MapMagic/Terrains/TerrainTile.cs:677)
Den.Tools.Tasks.ThreadManager.TaskThreadAction (Den.Tools.Tasks.ThreadManager+Task task) (at C:/Project/Assets/3rd Party/MapMagic/Tools/ThreadManager/ThreadManager.cs:142)

And also a code sample of how its been setup:

_mapMagic.ClearPreviewTile();

_mapMagic.graph = _terrainGraph;
_mapMagic.graph.random = new Noise(_keyword.GetHashCode());

_mapMagic.StartGenerate();


I am reporting this as a problem, since the exception is coming from mapMagic directly and looking thru the codebase I cannot see anything that could trigger this. It seems to be something to do with the async generation and the tileData not being locked, but I am not sure. I could not find reports of this anywhere else, so it could be something on our end of course.

Please let me know if you have any questions or need more info. Any advice is welcome

Thanks,
Radu

Radu , 29.11.2023, 11:45
Idea status: under consideration

Comments

Leave a comment