Create

Create

86M Downloads

[1.20.1] Issue when creating "fake" level off thread

CreativeMD opened this issue ยท 1 comments

commented

Describe the Bug

Hey there,
I'm the author of LittleTiles. Problem is that I create a level for an animation preview off thread (to avoid a freeze). Unfortunately this causes a crash with flywheel needing an open gl context:

FATAL ERROR in native method: Thread[ForkJoinPool.commonPool-worker-38,5,main]: No context is current or a function that is not available in the current context was called. The JVM will abort execution.
--
873 | at org.lwjgl.opengl.GL15C.nglDeleteBuffers([email protected] 7/Native Method)
874 | - parking to wait for  <0x0000000704d7ac40> (a java.util.concurrent.ForkJoinPool)
875 | at org.lwjgl.opengl.GL15C.glDeleteBuffers([email protected] 7/GL15C.java:142)
876 | at org.lwjgl.opengl.GL15.glDeleteBuffers([email protected] 7/GL15.java:160)
877 | at com.jozufozu.flywheel.backend.gl.buffer.GlBuffer.deleteInternal([email protected]/GlBuffer.java:102)
878 | at com.jozufozu.flywheel.backend.gl.GlObject.delete([email protected]/GlObject.java:38)
879 | at com.jozufozu.flywheel.backend.model.IndexedModel.delete([email protected]/IndexedModel.java:101)
880 | at com.jozufozu.flywheel.backend.model.ArrayModelRenderer.delete([email protected]/ArrayModelRenderer.java:52)
881 | at com.simibubi.create.content.contraptions.render.FlwContraption.invalidate([email protected]/FlwContraption.java:125)
882 | at com.simibubi.create.content.contraptions.render.ContraptionRenderingWorld.delete([email protected]/ContraptionRenderingWorld.java:104)
883 | at com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher$$Lambda$11267/0x000000080208ec88.accept([email protected]/Unknown Source)
884 | at java.util.HashMap$Values.forEach([email protected]/HashMap.java:1065)
885 | at com.jozufozu.flywheel.util.WorldAttached.empty([email protected]/WorldAttached.java:97)
886 | at com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher.reset([email protected]/ContraptionRenderDispatcher.java:204)
887 | at com.simibubi.create.CreateClient.invalidateRenderers([email protected]/CreateClient.java:95)
888 | at com.simibubi.create.foundation.events.ClientEvents.onLoadWorld([email protected]/ClientEvents.java:190)
889 | at com.simibubi.create.foundation.events.__ClientEvents_onLoadWorld_Load.invoke([email protected]/.dynamic)
890 | at net.minecraftforge.eventbus.ASMEventHandler.invoke(net.minecraftforge.eventbus/ASMEventHandler.java:73)
891 | at net.minecraftforge.eventbus.EventBus$$Lambda$4668/0x0000000801824628.invoke(net.minecraftforge.eventbus/Unknown Source)
892 | at net.minecraftforge.eventbus.EventBus.post(net.minecraftforge.eventbus/EventBus.java:315)
893 | at net.minecraftforge.eventbus.EventBus.post(net.minecraftforge.eventbus/EventBus.java:296)
894 | at net.minecraft.client.multiplayer.ClientLevel.<init>([email protected]/ClientLevel.java:182)
895 | at team.creative.littletiles.client.level.little.LittleClientLevel.<init>([email protected]/LittleClientLevel.java:69)
896 | at team.creative.littletiles.client.level.little.FakeClientLevel.<init>([email protected]/FakeClientLevel.java:41)

Not sure how to get around this issue. I would like to create this level off thread because it can take some time to set it up the animation, but I could also get around that (at least for the creation of the fake level). On the other hand I'm not sure why it requires the interaction with OpenGL in the first place. My guess it assumes it's a level like any other client level, which will cause issues even if it is executed on the main thread.

I also reported this issue to flywheel (Engine-Room/Flywheel#227), but @Jozufozu pointed out it is an issue of create itself.

Let me know what you think.

Reproduction Steps

  1. Install CreativeCore, LittleTiles and Create
  2. Create a simple blueprint
  3. Open the blueprint (the issue can be seen in the logs)
  4. Save the blueprint (the game will crash due to the issue before)

Mod Version

0.5.1f

Minecraft Version

1.20.1

commented

Fixed in the newest version of LittleTiles by moving the creation of the level to the main thread.