fix(pathfinding): disable chunk column snapshot for async A*#11
Draft
Deathtanium wants to merge 3 commits into
Draft
fix(pathfinding): disable chunk column snapshot for async A*#11Deathtanium wants to merge 3 commits into
Deathtanium wants to merge 3 commits into
Conversation
PathfindChunkCache stored WorldChunk references and read block states from pathfinder worker threads. Chunk column reads are not safe off the server thread while the main thread mutates the world, which can stall or corrupt async A*. Sync-batched jobs still snapshot columns on the server thread; async calculatePath now uses live world.getBlockState only (pre-cache behavior). Co-authored-by: Deathtanium <mishouro08@gmail.com>
…sync A* PathfindChunkCache now exposes buildColumnSnapshot (main thread) and liveWorldOnly. clamReach snapshots columns before queueing async work and passes the cache into calculatePath so workers reuse WorldChunk refs without getChunk. Adds calculatePath overload with optional prebuilt snapshot. Co-authored-by: Deathtanium <mishouro08@gmail.com>
When false, async reach passes null to calculatePath so pathfinding uses live ServerWorld#getBlockState only. Default true preserves column snapshot. Co-authored-by: Deathtanium <mishouro08@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Original fix: Async A* no longer called
getChunkfrom worker threads (unsafe). Chunk snapshot was disabled for async.Follow-up (this update): Restore efficient column caching for async by building the snapshot on the server thread right before
submitPathfinding, then passing it intocalculatePath. Workers only followWorldChunkreferences already resolved on the main thread—no redundant chunk-map work from the pool, without the previous threading hazard.PathfindChunkCache.buildColumnSnapshot(world, mod)— server thread onlyPathfindChunkCache.liveWorldOnly(world)— fallback when no snapshotcalculatePath(..., @Nullable PathfindChunkCache prebuilt)plus overload without the last arg (nullsnapshot)Verification
./gradlew build