Roughly Enough Items Fabric/Forge/NeoForge (REI)

Roughly Enough Items Fabric/Forge/NeoForge (REI)

40M Downloads

[Bug] NPE during rendering

warjort opened this issue ยท 1 comments

commented

Describe the bug
NPE when iterating widgets for rendering

Steps to Reproduce
This keeps happening with an incomplete Container I am developing.
I am not sure what it is doing that might be tweaking this bug?

Anyway, this usually happens when you have 2 threads modifying a LinkedList concurrently:

java.lang.NullPointerException: Rendering screen
        at java.util.LinkedList$ListItr.next(LinkedList.java:893)
        at me.shedaniel.rei.gui.ContainerScreenOverlay.renderWidgets(ContainerScreenOverlay.java:620)
        at me.shedaniel.rei.gui.ContainerScreenOverlay.render(ContainerScreenOverlay.java:529)
        at me.shedaniel.rei.RoughlyEnoughItemsCore.lambda$registerClothEvents$15(RoughlyEnoughItemsCore.java:537)
        at net.minecraft.client.gui.screens.Screen.handler$zil000$onPostDraw(Screen.java:2097)
        at net.minecraft.client.gui.screens.Screen.render(Screen.java:81)
        at net.minecraft.client.gui.screens.inventory.AbstractContainerScreen.render(AbstractContainerScreen.java:95)

Environment (please complete the following information with the version):
Minecraft Version: 1.16.5
Operating System: Windows 10 (amd64) version 10.0
Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), AdoptOpenJDK
fabric: Fabric API 0.32.5+1.16
roughlyenoughitems-runtime: REI (Runtime) 5.11.202

Additional context
I have tried turning off async search, but that doesn't help.

I guess if you used a CopyOnWriteArrayList the problem would go away, unless it is a sign of a more fundamental problem?

commented

I am closing this, as the problem is on my end.

It turns out I was causing the screen to be opened on a different thread to the rendering thread.
This was causing the concurrent access to that linked list.