From 9d0cf33a45cb319657d543a3841e680f98849e34 Mon Sep 17 00:00:00 2001 From: mcrcortex <18544518+MCRcortex@users.noreply.github.com> Date: Mon, 2 Jun 2025 11:47:12 +1000 Subject: [PATCH] Attempted fix for world timeout --- .../java/me/cortex/voxy/client/core/VoxyRenderSystem.java | 7 ++++--- src/main/java/me/cortex/voxy/commonImpl/VoxyInstance.java | 3 ++- .../java/me/cortex/voxy/commonImpl/WorldIdentifier.java | 4 ++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/cortex/voxy/client/core/VoxyRenderSystem.java b/src/main/java/me/cortex/voxy/client/core/VoxyRenderSystem.java index ef686e30..dc79e70c 100644 --- a/src/main/java/me/cortex/voxy/client/core/VoxyRenderSystem.java +++ b/src/main/java/me/cortex/voxy/client/core/VoxyRenderSystem.java @@ -61,6 +61,10 @@ public class VoxyRenderSystem { public final ChunkBoundRenderer chunkBoundRenderer; public VoxyRenderSystem(WorldEngine world, ServiceThreadPool threadPool) { + //Keep the world loaded, NOTE: this is done FIRST, to keep and ensure that even if the rest of loading takes more + // than timeout, we keep the world acquired + world.acquireRef(); + //Trigger the shared index buffer loading SharedIndexBuffer.INSTANCE.id(); Capabilities.init();//Ensure clinit is called @@ -86,9 +90,6 @@ public class VoxyRenderSystem { this.renderDistanceTracker.setRenderDistance(VoxyConfig.CONFIG.sectionRenderDistance); this.chunkBoundRenderer = new ChunkBoundRenderer(); - - //Keep the world loaded - this.worldIn.acquireRef(); } public void setRenderDistance(int renderDistance) { diff --git a/src/main/java/me/cortex/voxy/commonImpl/VoxyInstance.java b/src/main/java/me/cortex/voxy/commonImpl/VoxyInstance.java index bd8f7073..1e564452 100644 --- a/src/main/java/me/cortex/voxy/commonImpl/VoxyInstance.java +++ b/src/main/java/me/cortex/voxy/commonImpl/VoxyInstance.java @@ -131,7 +131,7 @@ public abstract class VoxyInstance { if (this.activeWorlds.containsKey(identifier)) { throw new IllegalStateException("Existing world with identifier"); } - Logger.info("Creating new world engine"); + Logger.info("Creating new world engine: " + identifier.getLongHash()); var world = new WorldEngine(this.createStorage(identifier), this); world.setSaveCallback(this.savingService::enqueueSave); this.activeWorlds.put(identifier, world); @@ -158,6 +158,7 @@ public abstract class VoxyInstance { var world = this.activeWorlds.remove(id); if (world == null) continue;//Race condition between unlock read and acquire write if (!world.isWorldIdle()) {this.activeWorlds.put(id, world); continue;}//No longer idle + Logger.info("Shutting down idle world: " + id.getLongHash()); //If is here close and free the world world.free(); } diff --git a/src/main/java/me/cortex/voxy/commonImpl/WorldIdentifier.java b/src/main/java/me/cortex/voxy/commonImpl/WorldIdentifier.java index c5eaa593..4baa6226 100644 --- a/src/main/java/me/cortex/voxy/commonImpl/WorldIdentifier.java +++ b/src/main/java/me/cortex/voxy/commonImpl/WorldIdentifier.java @@ -101,4 +101,8 @@ public class WorldIdentifier { seed = (seed ^ seed >>> 27) * -7723592293110705685L; return seed ^ seed >>> 31; } + + public long getLongHash() { + return this.hashCode; + } }