tr7zw/EntityCulling

1.19.2 Client Crash

Closed this issue · 4 comments

mxnmnm commented

I accidentally posted the issue to the wrong entityculling. If you need more info let me know Meldexun/EntityCulling#86

tr7zw commented
[06:47:17] [Render thread/ERROR]: Exception caught during firing event: null
	Index: 1
	Listeners:
		0: NORMAL
		1: ASM: class com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher renderLayer(Lcom/jozufozu/flywheel/event/RenderLayerEvent;)V
		2: ASM: class com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher renderLayer(Lcom/jozufozu/flywheel/event/RenderLayerEvent;)V
java.util.ConcurrentModificationException
	at java.base/java.util.HashMap$HashIterator.nextNode(HashMap.java:1597)
	at java.base/java.util.HashMap$ValueIterator.next(HashMap.java:1625)
	at TRANSFORMER/flywheel@0.6.10-20/com.jozufozu.flywheel.backend.instancing.instancing.InstancedMaterialGroup.renderAll(InstancedMaterialGroup.java:106)
	at TRANSFORMER/flywheel@0.6.10-20/com.jozufozu.flywheel.backend.instancing.instancing.InstancedMaterialGroup.render(InstancedMaterialGroup.java:76)
	at TRANSFORMER/flywheel@0.6.10-20/com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine.lambda$render$1(InstancingEngine.java:98)
	at java.base/java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1779)
	at java.base/java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:762)
	at TRANSFORMER/flywheel@0.6.10-20/com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine.render(InstancingEngine.java:98)
	at TRANSFORMER/flywheel@0.6.10-20/com.jozufozu.flywheel.backend.instancing.InstanceWorld.renderLayer(InstanceWorld.java:123)
	at TRANSFORMER/flywheel@0.6.10-20/com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher.renderLayer(InstancedRenderDispatcher.java:107)
	at TRANSFORMER/flywheel@0.6.10-20/com.jozufozu.flywheel.backend.instancing.__InstancedRenderDispatcher_renderLayer_RenderLayerEvent.invoke(.dynamic)
	at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73)
	at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:315)
	at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:296)
	at TRANSFORMER/minecraft@1.19.2/net.minecraft.client.renderer.LevelRenderer.handler$ceg000$renderLayer(LevelRenderer.java:14123)
	at TRANSFORMER/minecraft@1.19.2/net.minecraft.client.renderer.LevelRenderer.m_172993_(LevelRenderer.java:6200)
	at TRANSFORMER/minecraft@1.19.2/net.minecraft.client.renderer.LevelRenderer.m_109599_(LevelRenderer.java:1162)
	at TRANSFORMER/minecraft@1.19.2/net.minecraft.client.renderer.GameRenderer.m_109089_(GameRenderer.java:1068)
	at TRANSFORMER/minecraft@1.19.2/net.minecraft.client.renderer.GameRenderer.m_109093_(GameRenderer.java:840)
	at TRANSFORMER/minecraft@1.19.2/net.minecraft.client.Minecraft.m_91383_(Minecraft.java:1115)
	at TRANSFORMER/minecraft@1.19.2/net.minecraft.client.Minecraft.m_91374_(Minecraft.java:700)
	at TRANSFORMER/minecraft@1.19.2/net.minecraft.client.main.Main.m_239872_(Main.java:212)
	at TRANSFORMER/minecraft@1.19.2/net.minecraft.client.main.Main.main(Main.java:51)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at MC-BOOTSTRAP/fmlloader@1.19.2-43.3.5/net.minecraftforge.fml.loading.targets.CommonClientLaunchHandler.lambda$launchService$0(CommonClientLaunchHandler.java:27)
	at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:30)
	at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:53)
	at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:71)
	at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.Launcher.run(Launcher.java:106)
	at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.Launcher.main(Launcher.java:77)
	at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:26)
	at MC-BOOTSTRAP/cpw.mods.modlauncher@10.0.8/cpw.mods.modlauncher.BootstrapLaunchConsumer.accept(BootstrapLaunchConsumer.java:23)
	at cpw.mods.bootstraplauncher@1.1.2/cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:141)

[06:47:17] [Render thread/ERROR]: Unreported exception thrown!
java.util.ConcurrentModificationException: null
	at java.util.HashMap$HashIterator.nextNode(HashMap.java:1597) ~[?:?]
	at java.util.HashMap$ValueIterator.next(HashMap.java:1625) ~[?:?]
	at com.jozufozu.flywheel.backend.instancing.instancing.InstancedMaterialGroup.renderAll(InstancedMaterialGroup.java:106) ~[flywheel-forge-1.19.2-0.6.10-20.jar%23498!/:0.6.10-20]
	at com.jozufozu.flywheel.backend.instancing.instancing.InstancedMaterialGroup.render(InstancedMaterialGroup.java:76) ~[flywheel-forge-1.19.2-0.6.10-20.jar%23498!/:0.6.10-20]
	at com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine.lambda$render$1(InstancingEngine.java:98) ~[flywheel-forge-1.19.2-0.6.10-20.jar%23498!/:0.6.10-20]

That crash is in flywheel, nothing related to entityculling.

That crash is in flywheel, nothing related to entityculling.

I disagree; these issues are probably being caused by accessing the client world directly inside the CullTask, which runs off-thread. The client world is not thread-safe and anything working with it off-thread needs to do so very carefully, by first making a snapshot of the needed data on the main thread.

One of your accesses probably triggers a Flywheel event handler to run and change one of the maps it uses for rendering from the culling thread.

tr7zw commented

Many people have been running the two mods for a long time together without issues. If they had some actual incompatibility i would get flooded with issues. Yes, entity culling reads data in a technically unsafe way and handles potential issues that it faces due to that internally(entity list changing, causeing the concurrent modification exception in the cull thread). It always ever gets/reads data via the normal Mc methods. This concurrent modification exception is in internal render logic of flywheel, two things this mod has nothing to do with.
I doubt getting if some block is a solid block or the loaded entity list has some side effect in the getter that leads into updating internal render maps of flywheel(and if it did I want to talk to the person that added such sideeffects to a vanilla getter).

tr7zw commented

For completeness sake on why I decided to do it like this: I know that you'd would use snapshots n stuff to async process for example the map. But in this case, getting the correct info isn't essential(a block changing mid trace doesn't cause issues), and the culling thread getting interrupted by a concurrent modification exception of the entity list is prefered over the overhead caused by either creating the world snapshots, creating defensive copies or trying to create some sync/lock system between the cull and game thread. With this current setup, worst case things get updated one cull tick later, and the game is non the wiser in terms of performance penalty that stuff is even happening.