Fail if render screen never activates
This commit is contained in:
+18
-1
@@ -28,6 +28,7 @@ import net.minecraft.world.item.ItemStack;
|
|||||||
|
|
||||||
public final class RenderCatalogClient implements ClientModInitializer {
|
public final class RenderCatalogClient implements ClientModInitializer {
|
||||||
private static final Gson GSON = new Gson();
|
private static final Gson GSON = new Gson();
|
||||||
|
private static final long SCREEN_ACTIVATION_TIMEOUT_MILLIS = 30_000L;
|
||||||
private static final long CAPTURE_TIMEOUT_MILLIS = 120_000L;
|
private static final long CAPTURE_TIMEOUT_MILLIS = 120_000L;
|
||||||
|
|
||||||
private final List<RenderJob> jobs = new ArrayList<>();
|
private final List<RenderJob> jobs = new ArrayList<>();
|
||||||
@@ -62,6 +63,22 @@ public final class RenderCatalogClient implements ClientModInitializer {
|
|||||||
System.out.println("[renderer] opening render screen");
|
System.out.println("[renderer] opening render screen");
|
||||||
client.setScreenAndShow(renderScreen);
|
client.setScreenAndShow(renderScreen);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Thread activationWatchdog = new Thread(() -> {
|
||||||
|
try {
|
||||||
|
Thread.sleep(SCREEN_ACTIVATION_TIMEOUT_MILLIS);
|
||||||
|
} catch (InterruptedException exception) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!renderScreen.activated) {
|
||||||
|
System.err.println("[renderer] render screen never activated within " + SCREEN_ACTIVATION_TIMEOUT_MILLIS + "ms");
|
||||||
|
Runtime.getRuntime().halt(1);
|
||||||
|
}
|
||||||
|
}, "renderer-activation-watchdog");
|
||||||
|
activationWatchdog.setDaemon(true);
|
||||||
|
activationWatchdog.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadJobs(Path manifestPath) throws IOException {
|
private void loadJobs(Path manifestPath) throws IOException {
|
||||||
@@ -222,7 +239,7 @@ public final class RenderCatalogClient implements ClientModInitializer {
|
|||||||
private final class RenderScreen extends Screen {
|
private final class RenderScreen extends Screen {
|
||||||
private boolean captureQueued;
|
private boolean captureQueued;
|
||||||
private long captureQueuedAtMillis;
|
private long captureQueuedAtMillis;
|
||||||
private boolean activated;
|
private volatile boolean activated;
|
||||||
|
|
||||||
private RenderScreen() {
|
private RenderScreen() {
|
||||||
super(Component.literal("Rendering renameable items"));
|
super(Component.literal("Rendering renameable items"));
|
||||||
|
|||||||
Reference in New Issue
Block a user