Skip to content

Load the LOD world engine off the render thread on level reload (fix join freeze)#574

Open
Kishku7 wants to merge 1 commit into
MCRcortex:devfrom
Kishku7:fix/async-lod-store-load
Open

Load the LOD world engine off the render thread on level reload (fix join freeze)#574
Kishku7 wants to merge 1 commit into
MCRcortex:devfrom
Kishku7:fix/async-lod-store-load

Conversation

@Kishku7

@Kishku7 Kishku7 commented Jun 20, 2026

Copy link
Copy Markdown

Summary

LevelRenderer.allChanged builds the Voxy renderer synchronously, which opens and indexes the per-world LOD store (RocksDB open + Mapper/palette load) on the render thread. For a large store this freezes the client for several seconds on every join / dimension change.

Fix

Build the WorldEngine on a background thread, then create the GL-bound VoxyRenderSystem back on the render thread once it's ready. A generation counter (bumped on every shutdown/create, all on the render thread) lets an in-flight load detect that it has been superseded by a level change / disconnect / reload and discard itself safely. The GL object is still created on the render thread; only the disk I/O moves off it.

Scope / testing

One file (MixinLevelRenderer). Tested on MC 26.1.2 with a large LOD store (alongside VoxyServer): the join freeze is eliminated; LODs fill in a moment later as the engine finishes loading.

Note for maintainer

VoxyInstance.getOrCreate still holds its StampedLock write lock across the build - now off the render thread, so it no longer freezes rendering, but it can briefly block other getOrCreate callers (e.g. ingest) during the first load. Relaxing that lock is a deeper change left out of scope here.


Happy to discuss any of this - you can reach me on my Discord: https://discord.gg/2ZxzbCzAHe

LevelRenderer.allChanged opened and indexed the per-world LOD store (RocksDB open + Mapper load) synchronously on the render thread, freezing the client for several seconds on join for large stores. Build the engine on a background thread and create the GL VoxyRenderSystem back on the render thread once ready, guarded by a generation counter so level changes/disconnects mid-load are handled safely.
@wahfl2

wahfl2 commented Jun 20, 2026

Copy link
Copy Markdown

you can reach me on my Discord

Cortex has a discord server, that's probably where this should be discussed: https://discord.gg/teErFatQv9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants