Entity Culling Fabric/Forge

Entity Culling Fabric/Forge

80M Downloads

ConcurrentModifictionException error

campbebj opened this issue ยท 5 comments

commented

Hey im getting the following error and then my client is just freezing up after that. I think it might be a reaction to be displaying litematica schematics but im not 100% sure. is there anything i can provide to help with debugging?

[16:38:09] [CullThread/INFO]: [STDERR]: java.util.ConcurrentModificationException
[16:38:09] [CullThread/INFO]: [STDERR]: at java.util.HashMap$HashIterator.nextNode(HashMap.java:1445)
[16:38:09] [CullThread/INFO]: [STDERR]: at java.util.HashMap$EntryIterator.next(HashMap.java:1479)
[16:38:09] [CullThread/INFO]: [STDERR]: at java.util.HashMap$EntryIterator.next(HashMap.java:1477)
[16:38:09] [CullThread/INFO]: [STDERR]: at dev.tr7zw.entityculling.CullTask.run(CullTask.java:56)
[16:38:09] [CullThread/INFO]: [STDERR]: at java.lang.Thread.run(Thread.java:748)

commented

Hmm I have no clue how litematica schematics are rendered, but yea it might be an issue with that. But that at worst should kill the cull thread, not freeze up the client. I'll look into it.

commented

I don't think it's an issue with Litematica as I'm getting the error as well.

[03:06:37] [CullThread/INFO]: [STDERR]: java.util.ConcurrentModificationException
[03:06:37] [CullThread/INFO]: [STDERR]: 	at java.base/java.util.HashMap$HashIterator.nextNode(HashMap.java:1584)
[03:06:37] [CullThread/INFO]: [STDERR]: 	at java.base/java.util.HashMap$EntryIterator.next(HashMap.java:1617)
[03:06:37] [CullThread/INFO]: [STDERR]: 	at java.base/java.util.HashMap$EntryIterator.next(HashMap.java:1615)
[03:06:37] [CullThread/INFO]: [STDERR]: 	at dev.tr7zw.entityculling.CullTask.run(CullTask.java:56)
[03:06:37] [CullThread/INFO]: [STDERR]: 	at java.base/java.lang.Thread.run(Thread.java:831)

Perhaps you could use a ConcurrentHashMap if you're using multiple threads? Typical operations still don't require synchronization, so I don't think performance would be a big issue, and a ConcurrentHashMap can be iterated over and modified by different threads.

My mod list:

	Fabric Mods: 
		advancements-enlarger: Advancements Enlarger 0.2.3
		amecs: Amecs 1.3.3+mc.1.16.3
		amecsapi: Amecs API 1.1.3+mc1.16.5
		angerable-patch: Angerable Patch 1.1.0-1.16.4
		appleskin: AppleSkin 1.0.11
		architectury: Architectury 1.8.131
		artifice: Artifice 0.14.6+1.16.5
		autoconfig1u: Auto Config v1 Updated 3.3.1
		beaconsforall: Beacons For All 1.4.1-1.16.5
		betterdroppeditems: Better Dropped Items 1.2.4-1.16.2
		bettergraves: Better Graves 0.4.1
		bettersleeping: Better Sleeping 0.4.0
		betterthanmending: BetterThanMending 1.3.0
		blue_endless_jankson: jankson 1.2.0
		cameraoverhaul: Camera Overhaul 1.2.2-fabric-universal
		can-i-mine-this-block: cAn i MiNe thIS bLOCk? 1.0.2
		carpet: Carpet Mod in Fabric 1.4.28
		carpet-extra: Carpet Extra 1.4.27
		cloth-basic-math: Cloth Basic Math 0.5.1
		cloth-client-events-v0: Cloth Client Events v0 1.5.47
		cloth-config2: Cloth Config v4 4.11.14
		colormatic: Colormatic 2.2.8+mc.1.16.3
		com_github_shevek_parallelgzip: parallelgzip master-SNAPSHOT
		com_moandjiezana_toml_toml4j: toml4j 0.7.2
		com_squareup_moshi_moshi: moshi 1.9.2
		com_squareup_okio_okio: okio 1.16.0
		cotton-config: Cotton Config 1.0.0-rc.7
		cotton-logging: Cotton Logging 1.0.0-rc.4
		craftpresence: CraftPresence 1.7.6
		dynamicfps: Dynamic FPS 2.0.1
		dynamicsoundfilters: Dynamic Sound Filters 1.2.0+1.16.5
		elytra_swap: Elytra Swap 2.2.0-1.16.2
		enhancedblockentities: Enhanced Block Entities 0.1
		entityculling: EntityCulling-Fabric 1.0.2
		fabric: Fabric API 0.32.0+1.16
		fabric-api-base: Fabric API Base 0.2.1+9354966b7d
		fabric-api-lookup-api-v1: Fabric API Lookup API (v1) 1.0.0+dc716ea17d
		fabric-biome-api-v1: Fabric Biome API (v1) 3.1.1+ca58154a7d
		fabric-blockrenderlayer-v1: Fabric BlockRenderLayer Registration (v1) 1.1.5+ca58154a7d
		fabric-command-api-v1: Fabric Command API (v1) 1.1.0+f9b3753b7d
		fabric-commands-v0: Fabric Commands (v0) 0.2.2+ca58154a7d
		fabric-containers-v0: Fabric Containers (v0) 0.1.11+9354966b7d
		fabric-content-registries-v0: Fabric Content Registries (v0) 0.2.1+ca58154a7d
		fabric-crash-report-info-v1: Fabric Crash Report Info (v1) 0.1.3+ca58154a7d
		fabric-diagonal-panes: Fabric Diagonal Panes 0.4.0
		fabric-dimensions-v1: fabric-dimensions-v1 2.0.6+9354966b7d
		fabric-entity-events-v1: Fabric Entity Events (v1) 1.0.3+ca58154a7d
		fabric-events-interaction-v0: Fabric Events Interaction (v0) 0.4.2+ca58154a7d
		fabric-events-lifecycle-v0: Fabric Events Lifecycle (v0) 0.2.1+ca58154a7d
		fabric-game-rule-api-v1: Fabric Game Rule API (v1) 1.0.6+ca58154a7d
		fabric-item-api-v1: Fabric Item API (v1) 1.2.1+ca58154a7d
		fabric-item-groups-v0: Fabric Item Groups (v0) 0.2.3+ca58154a7d
		fabric-key-binding-api-v1: Fabric Key Binding API (v1) 1.0.4+9354966b7d
		fabric-keybindings-v0: Fabric Key Bindings (v0) 0.2.1+ca58154a7d
		fabric-language-kotlin: Fabric Language Kotlin 1.4.21+build.1
		fabric-lifecycle-events-v1: Fabric Lifecycle Events (v1) 1.2.1+ca58154a7d
		fabric-loot-tables-v1: Fabric Loot Tables (v1) 1.0.2+ca58154a7d
		fabric-mining-levels-v0: Fabric Mining Levels (v0) 0.1.3+ca58154a7d
		fabric-models-v0: Fabric Models (v0) 0.2.1+ca58154a7d
		fabric-mumblelink-mod: MumbleLink 0.7.5
		fabric-networking-api-v1: Fabric Networking API (v1) 1.0.1+ca58154a7d
		fabric-networking-blockentity-v0: Fabric Networking Block Entity (v0) 0.2.8+ca58154a7d
		fabric-networking-v0: Fabric Networking (v0) 0.3.2+ca58154a7d
		fabric-object-builder-api-v1: Fabric Object Builder API (v1) 1.9.4+9354966b7d
		fabric-object-builders-v0: Fabric Object Builders (v0) 0.7.2+ca58154a7d
		fabric-particles-v1: Fabric Particles (v1) 0.2.4+ca58154a7d
		fabric-registry-sync-v0: Fabric Registry Sync (v0) 0.7.4+ca58154a7d
		fabric-renderer-api-v1: Fabric Renderer API (v1) 0.4.1+ca58154a7d
		fabric-renderer-indigo: Fabric Renderer - Indigo 0.4.4+ca58154a7d
		fabric-renderer-registries-v1: Fabric Renderer Registries (v1) 2.2.1+ca58154a7d
		fabric-rendering-data-attachment-v1: Fabric Rendering Data Attachment (v1) 0.1.5+ca58154a7d
		fabric-rendering-fluids-v1: Fabric Rendering Fluids (v1) 0.1.13+ca58154a7d
		fabric-rendering-v0: Fabric Rendering (v0) 1.1.2+ca58154a7d
		fabric-rendering-v1: Fabric Rendering (v1) 1.5.1+ca58154a7d
		fabric-resource-loader-v0: Fabric Resource Loader (v0) 0.4.2+ca58154a7d
		fabric-screen-api-v1: Fabric Screen API (v1) 1.0.0+c045166c7d
		fabric-screen-handler-api-v1: Fabric Screen Handler API (v1) 1.1.5+9354966b7d
		fabric-start-the-music: Start the Music! 0.2.1
		fabric-structure-api-v1: Fabric Structure API (v1) 1.1.4+ca58154a7d
		fabric-tag-extensions-v0: Fabric Tag Extensions (v0) 1.1.1+ca58154a7d
		fabric-textures-v0: Fabric Textures (v0) 1.0.6+ca58154a7d
		fabric-tool-attribute-api-v1: Fabric Tool Attribute API (v1) 1.2.6+ca58154a7d
		fabric-tree-chopper: Fabric Tree Chopper 0.6.1
		fabricloader: Fabric Loader 0.11.2
		fairenchanting: FairEnchanting 1.2.0
		fiber: fiber 0.23.0-2
		fiber2cloth: Fiber To Cloth 3.1.0
		harvest: Harvest 1.2.12
		hydrogen: Hydrogen 0.2-SNAPSHOT
		indium: Indium 1.0.0
		inventorysorter: Inventory Sorter 1.7.7-1.16
		iris: Iris 0.2.0-sodium_compatibility
		itemmodelfix: Item Model Fix 1.0.0
		jankson: Jankson 3.0.1+j1.2.0
		java: OpenJDK 64-Bit Server VM 16
		kirin: Kirin UI 1.7-1.16.2
		krypton: Krypton 0.1.2
		kyrptconfig: Kytpt Config 1.1.6-1.16
		lambdabettergrass: LambdaBetterGrass 1.0.3+1.16
		lambdynlights: LambDynamicLights 1.3.4+1.16
		lazydfu: LazyDFU 0.1.2
		lightoverlay: Light Overlay 5.8.0
		lithium: Lithium 0.6.4-SNAPSHOT
		malilib: MaLiLib 0.10.0-dev.21+arne.2
		minecraft: Minecraft 1.16.5
		mm: Manningham Mills 2.1
		modmenu: Mod Menu 1.16.8
		modupdater: ModUpdater 1.1.11+1.16.2-rc2
		mostructures: Mo' Structures 1.1.0+mc.1.16.5
		mousewheelie: Mouse Wheelie 1.6.4+mc1.16.4
		net_gegy1000_just-now: just-now 0.1.0-SNAPSHOT
		notenoughanimations: NotEnoughAnimations 1.0.3
		notenoughcrashes: Not Enough Crashes 3.1.8
		okzoomer: Ok Zoomer 4.0.1+1.16.2
		org_apache_commons_commons-compress: commons-compress 1.19
		org_aperlambda_lambdajcommon: lambdajcommon 1.8.1
		org_codehaus_groovy_groovy: groovy 3.0.3
		org_codehaus_groovy_groovy-jsr223: groovy-jsr223 3.0.3
		org_jetbrains_annotations: annotations 20.0.0
		org_jetbrains_kotlin_kotlin-reflect: kotlin-reflect 1.4.21
		org_jetbrains_kotlin_kotlin-stdlib: kotlin-stdlib 1.4.21
		org_jetbrains_kotlin_kotlin-stdlib-jdk7: kotlin-stdlib-jdk7 1.4.21
		org_jetbrains_kotlin_kotlin-stdlib-jdk8: kotlin-stdlib-jdk8 1.4.21
		org_jetbrains_kotlinx_kotlinx-coroutines-core: kotlinx-coroutines-core 1.3.7
		org_jetbrains_kotlinx_kotlinx-coroutines-core-jvm: kotlinx-coroutines-core-jvm 1.4.2
		org_jetbrains_kotlinx_kotlinx-coroutines-jdk8: kotlinx-coroutines-jdk8 1.4.2
		org_tukaani_xz: xz 1.8
		presencefootsteps: Presence Footsteps r29+1.16.4
		repurposed_structures: Repurposed Structures 1.16.5-1.8.6
		roughlyenoughitems: Roughly Enough Items 5.10.184
		roughlyenoughitems-api: REI (API) 5.10.184
		roughlyenoughitems-default-plugin: REI (Default Plugin) 5.10.184
		roughlyenoughitems-runtime: REI (Runtime) 5.10.184
		roughlyenoughresources: Roughly Enough Resources 2.1.3
		screenshotclipboard: Screenshot to Clipboard 1.0.6
		seamless_loading_screen: Seamless Loading Screen 1.3.1
		slight-gui-modifications: 'Slight' GUI Modifications 1.7.1
		smoothscrollingeverywhere: Smooth Scrolling Everywhere 3.0.3-unstable
		sneak-through-berries: Sneak Through Berries 1.1.0+1.16.4-fabric
		sodium: Sodium IRIS-SNAPSHOT
		spark: spark 1.4.3
		spruceui: SpruceUI 2.0.4+1.16
		starlight: Starlight 0.0.3
		textile_backup: Textile Backup 2.1.0-prev-1.16.4
		the_loved_ones: The Loved Ones 1.1.0+1.16.4
		tic_tacs: Tic-TACS 0.1.3
		tweakeroo: Tweakeroo 0.10.0-dev.20210303.123654
		tweed: Tweed API 3.0.0-beta.22
		voyager: Voyager 1.0.0
		waila: Hwyla 1.9.22
		worldedit: WorldEdit 7.2.0-SNAPSHOT+5279-a8bba3b
		worldeditcui: worldeditcui 1.16.1
commented
Perhaps you could use a ConcurrentHashMap if you're using multiple threads? Typical operations still don't require synchronization, so I don't think performance would be a big issue, and a ConcurrentHashMap can be iterated over and modified by different threads.

A ConcurrentHashMap does synchronize internally, also this map is not a map I control(the blockentity map). You are 2 versions behind, the release yesterday hides this exceptions since it's not of relevant(at worst the culling is 10ms outdated, that is less than one frame on a 60hz monitor).

commented

That's my bad, I forgot to mark this mod to be checked for updated by my mod manager.

Wrapping a map with Collections.synchronizedMap() does synchronize internally on all calls. However, a ConcurrentHashMap doesn't synchronize on gets or iteration at all, and only synchronizes on individual bins in the map if the bins aren't empty when a put is issued.

I don't think a quick @Redirect for the original map constructor (wherever it is) would be terrible if it means you don't have to use a janky non-deterministic hack like this.

commented

Like I noted in the comment on that code, I don't think there is any value to be gained by using mixins to put a ConcurrentHashMap into there. I mean it sure can be done, but in the end it's just more stuff to maintain(especially in regards to other mods that might touch that like Lithium) without any visible end user benefits other than it being ever so slightly slower.
The entire culling process is running async to the main thread, so it has to be able to handle stuff unexpectedly changing like the world turning null/chunks not being loaded any more or in this case the block-/entity maps not being async friendly.