Fabric API

Fabric API

106M Downloads

1.15pre-1 batching chunks NPE

Draylar opened this issue ยท 5 comments

commented

Versions:

  • API 0.4.13+build.264-1.15
  • Minecraft 1.15-pre1
  • Loader 0.7.1+build.173
  • Yarn 3:v2

My game is randomly crashing while flying around new dev worlds with the following error. The only noticeable additions to my game are:

  • a simple custom lake feature
  • a custom fluid, which worked on all previous versions

It seems like the erroring method is MixinChunkRebuildTask#hookChunkBuild, but I can't reproduce the error reliably enough to track down the cause.

commented

Will take a look at this one. Appears to be an Indigo issue - not exactly sure of cause but I have a notion.

commented

same crash outside of a development environment: https://paste.ee/p/IXFYV
(pack is AOF-2 v0.1.0)

commented

I did explore this:

Region here MixinChunkRebuildTask.java#L74 gets set to null off thread.

Adding a Thread.sleep(50); call before ((AccessChunkRendererRegion) region).fabric_setRenderer(renderer); makes it easily reproducable.

Assgining region to a local var is a quick fix but it didnt feel right.

commented

Assgining region to a local var is a quick fix but it didnt feel right.

That's the fix. Assignment to a local var is also what vanilla does to prevent this.

This is happening because the chunk rebuild is being cancelled after the initial retrieval and before the cast. Typically this would happen because of rapid updates to the same chunk. IIRC, when the an update is scheduled, it cancels any update already in flight. Cancelling sets the region field to null.

This bug doesn't appear to be new, but is more likely to occur now due to heavier concurrent chunk loading activity.

Capturing the region as a local variable will prevent this, and if the rebuild is cancelled before our mixin exits then the vanilla logic will detect that and exit without rebuilding.

Even if a rebuild does happen after cancel it doesn't cause a problem other than wasting compute resources when the chunk is rebuilt and buffered again in a frame or two.

I can include this with the item rendering fix unless you want to segregate or fast track it.

commented

I can push it right out, glad to know that it is the correct fix, I wasnt too sure.