render: (hopefully) fix SIGSEGV jvm crash

It looks like that the jvm crashes when preparing the render window while JavaFX is launching an window. Weired.
This commit is contained in:
Bixilon 2020-11-03 22:57:56 +01:00
parent 687410bc31
commit 445643f23d
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
3 changed files with 7 additions and 10 deletions

View File

@ -164,7 +164,7 @@ public final class Minosoft {
GameWindow.prepare();
progress.countDown();
}, "Game Window", "", Priorities.NORMAL, TaskImportance.REQUIRED, "Assets"));
}, "Game Window", "", Priorities.NORMAL, TaskImportance.REQUIRED, "Assets", "Progress Window"));
taskWorker.work(startStatusLatch);
try {

View File

@ -98,14 +98,6 @@ public class AssetsManager {
e.printStackTrace();
}
});
// ToDo: This is strange. You will get a jvm crash without it on linux. Weired.
/*
try {
Thread.sleep(500L);
} catch (InterruptedException e) {
e.printStackTrace();
}
*/
generateJarAssets();
assets.putAll(parseAssetsIndex(ASSETS_CLIENT_JAR_HASH));
latch.countDown();

View File

@ -34,12 +34,14 @@ public class StartProgressWindow extends Application {
public static Dialog<Boolean> progressDialog;
private static boolean exit = false;
public static void show(CountUpAndDownLatch progress) {
public static void show(CountUpAndDownLatch progress) throws InterruptedException {
if (exit) {
return;
}
CountDownLatch latch = new CountDownLatch(1);
new Thread(() -> {
if (progress.getCount() == 0) {
latch.countDown();
return;
}
AtomicReference<ProgressBar> progressBar = new AtomicReference<>();
@ -59,11 +61,13 @@ public class StartProgressWindow extends Application {
stage.initModality(Modality.APPLICATION_MODAL);
stage.setOnCloseRequest((request) -> System.exit(0));
if (exit) {
latch.countDown();
return;
}
progressDialog.show();
stage.toFront();
});
latch.countDown();
while (progress.getCount() > 0) {
try {
progress.waitForChange();
@ -77,6 +81,7 @@ public class StartProgressWindow extends Application {
}
hideDialog();
}).start();
latch.await();
}
public static void start() throws InterruptedException {