From ca2014802a9925917355b6448e8881293fbb0f80 Mon Sep 17 00:00:00 2001 From: OLEGSHA Date: Wed, 18 Aug 2021 09:30:29 +0300 Subject: [PATCH] Resolved a random deadlock that became way too frequent to ignore There was a deadlock that sometimes occurred when passing PacketSetBlock to client: PacketSetBlock first acquired monitor of the chunk it modified, than attempted to lock the visible chunks set. In parallel, a chunk update first acquires the visible chunks, than the individual chunk. Turns out, markForUpdate() doesn't need to be synchronized, so PacketSetBlock can now acquire the locks sequentially, avoiding the deadlock. --- .../java/ru/windcorp/progressia/client/world/ChunkRender.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/ru/windcorp/progressia/client/world/ChunkRender.java b/src/main/java/ru/windcorp/progressia/client/world/ChunkRender.java index e96166d..41aa933 100644 --- a/src/main/java/ru/windcorp/progressia/client/world/ChunkRender.java +++ b/src/main/java/ru/windcorp/progressia/client/world/ChunkRender.java @@ -97,7 +97,7 @@ public class ChunkRender return data; } - public synchronized void markForUpdate() { + public void markForUpdate() { getWorld().markChunkForUpdate(getPosition()); }