Construction Wand

Construction Wand

22M Downloads

Crash on Client Startup 1.16.5-2.1

kreezxil opened this issue · 12 comments

commented

https://gist.github.com/ce43cbd433a3a52bbaed60c30efb8f0b

Seems to be related to 1.16.5-36.1.4

Doesn't crash a dedicated server tho on this same forge build.

Just tried it on Forge 1.16.5-36.1.2, and it did not crash the client.

Just tried again on 36.1.4 and this time it did not crash the client.

I'll leave this here, you can kill it after a month if no one adds to or I don't find more info on it.

commented

Hi @kreezxil,
I just tried it myself on both Java8 and 11 and could not reproduce the issue.

Then I did some further investigation. Here are the functions in question based on your error report:

constructionwand.items.ModItems.registerModelProperties (my code)

@OnlyIn(Dist.CLIENT)
public static void registerModelProperties() {
    for(Item item : WANDS) {
        ItemModelsProperties.func_239418_a_(
                item, ConstructionWand.loc("using_core"),
                (stack, world, entity) -> entity == null || !(stack.getItem() instanceof ItemWand) ? 0 :
                        new WandOptions(stack).cores.get().getColor() > -1 ? 1 : 0
        );
    }
}

minecraft.item.ItemModelsProperties.func_239418_a_ (Minecraft code)

public static void func_239418_a_(Item item, ResourceLocation resourceLocation, IItemPropertyGetter getter) {
   field_239415_f_.computeIfAbsent(item, (x) -> {
      return Maps.newHashMap();
   }).put(resourceLocation, getter);
}

java.util.HashMap.computeIfAbsent (Java code)

int mc = this.modCount;
v = mappingFunction.apply(key);
   if (mc != this.modCount) {
       throw new ConcurrentModificationException();

Appearently you must not modify a HashMap in the function passed into ComputeIfAbsent. Otherwise the exception noted in your crash report gets thrown.
How that could have happened - no idea. All that function (x) -> { return Maps.newHashMap(); } does is return a new HashMap to be inserted as new item, not modify the main one.

Guess I'll do what you suggested. I'll leave the issue open for a month or so. If you encounter another crash, send me the report.

thx for reporting anyway

commented
commented

I still can't reproduce the issue myself. Might have an idea though.
It could be that the HashMap holding the model properties gets modified in another thread.
So maybe there is another mod registering custom model properties at the same time?
That would explain why it crashes only sometimes (these kind of race conditions are the worst to reproduce and debug).
Could you tell me which modpack you are using? I might be able to reproduce it that way.

I looked at the Botania mod (they are using custom item models and colors for example for the Wand of the Forest).
Appearently they are running the model properties and color registry stuff using a queue.

event.enqueueWork(ClientProxy::registerPropertyGetters);

https://github.com/Vazkii/Botania/blob/3bc7cf88f243a65b0b61f206bcd74525cf9417a4/src/main/java/vazkii/botania/client/core/proxy/ClientProxy.java#L160

So maybe I should do this, too.
Can I send you a version of my mod with that change for testing? If that fixes the issue, I'll release it.

commented

ok it did it again. on startup, I wish it would do it during gameplay.

https://gist.github.com/c6d4ab602fa025a0621689efe6108373

commented

It's my new pack Sky Stream Madness, version 2.2.3 is the last version with your construction wand in it. And it was crashing on client startup rather consistently, the server doesn't however.

Do note there is an odd issue, where you can re-enter a singleplayer world without restarting the client. I haven't figured out if it is a mod issue or a forge issue.

commented

I have tested Sky Stream Madness 2.2.3 on my machine, but I could not get it to crash on startup.

Here you have a test version of Construction Wand which might fix the issue. Would you test it on your machine and tell me if it works or crashes? If it is OK, I'll publish it as a new update.

constructionwand-1.16.5-2.2_TEST.zip

Info: Unzip the file before adding it to your mod folder, GitHub does not like jar file attachments. And use this file for testing and private purposes only and dont publish it. Would be a nightmare to support.

Thank you in advance.

commented
commented

I have tested it with both Java8 and Java11 on 2 machines and did not have any crashes.

Have you tried the test version that I linked in the post above?
It might fix the issue, but I would need your confirmation since I cant test it myself.

commented

the test mod worked, i didn't get an issue starting up the pack.

commented
commented

Okay. Guess I'll publish it then.

Thank you for testing.

PS: you dont have to send direct replies to me, I'm subscribed to this repository and get all updates into my inbox.

commented

Released ConstructionWand 2.2 which (probably) fixes the issue.