Improve render load error handling

This commit is contained in:
James Seibel
2026-02-08 21:06:01 -06:00
parent 78f83197d7
commit 9f22e3f2b3
@@ -164,36 +164,44 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable
return false; return false;
} }
CompletableFuture<Void> future = new CompletableFuture<>();
future.handle((voidObj, throwable) ->
{
// the task is done, we don't need to track these anymore
this.getAndBuildRenderDataFuture = null;
this.getAndBuildRenderDataRunnable = null;
return null;
});
try try
{ {
CompletableFuture<Void> future = new CompletableFuture<>();
this.getAndBuildRenderDataFuture = future; this.getAndBuildRenderDataFuture = future;
future.handle((voidObj, throwable) ->
{
// the task is done, we don't need to track these anymore
this.getAndBuildRenderDataFuture = null;
this.getAndBuildRenderDataRunnable = null;
return null;
});
this.getAndBuildRenderDataRunnable = () -> this.getAndBuildRenderDataRunnable = () ->
{ {
this.refreshActiveBeaconList(); try
LodQuadBuilder lodQuadBuilder = this.getAndBuildRenderData();
if (lodQuadBuilder == null)
{ {
future.complete(null); this.refreshActiveBeaconList();
return;
} LodQuadBuilder lodQuadBuilder = this.getAndBuildRenderData();
if (lodQuadBuilder == null)
this.uploadToGpuAsync(lodQuadBuilder)
.thenRun(() ->
{ {
// the future is passed in separately (IE not using the local var) to prevent any possible race condition null pointers
future.complete(null); future.complete(null);
}); return;
}
this.uploadToGpuAsync(lodQuadBuilder)
.thenRun(() ->
{
// the future is passed in separately (IE not using the local var) to prevent any possible race condition null pointers
future.complete(null);
});
}
catch (Exception e)
{
LOGGER.error("Unexpected issue creating render data for pos: ["+DhSectionPos.toString(this.pos)+"], error: ["+e.getMessage()+"].", e);
future.complete(null);
}
}; };
executor.execute(this.getAndBuildRenderDataRunnable); executor.execute(this.getAndBuildRenderDataRunnable);
@@ -201,7 +209,7 @@ public class LodRenderSection implements IDebugRenderable, AutoCloseable
} }
catch (RejectedExecutionException ignore) catch (RejectedExecutionException ignore)
{ {
this.getAndBuildRenderDataFuture.complete(null); future.complete(null);
/* the thread pool was probably shut down because it's size is being changed, just wait a sec and it should be back */ /* the thread pool was probably shut down because it's size is being changed, just wait a sec and it should be back */
return false; return false;