Architectury API (Fabric/Forge/NeoForge)

Architectury API (Fabric/Forge/NeoForge)

158M Downloads

Thread safety of ItemPropertiesRegistry.register on Forge

zbx1425 opened this issue ยท 2 comments

commented

ItemPropertiesRegistry.register calls the vanilla ItemProperties.register, which does computeIfAbsent on a static HashMap, which is not thread safe.
When calling it from CLIENT_SETUP which is called from the parallel executing FMLClientSetupEvent, there can be read/write conflicts with other mods and result in ConcurrentModificationException.

This is not an issue on Fabric since it doesn't execute entry point functions in multiple threads.

Is this an Architectury API issue, or if I should call ItemPropertiesRegistry.register from somewhere else?
I've read the Architectury API documentation didn't notice entries mentioning thread safety.

commented

Yes, this happened to me too

commented

Oh yeah, my game just crashed because of this.
"Architectury encountered an error during the common_stup event phase"
java.util.ConcurrentModificationException: null