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(); GameWindow.prepare();
progress.countDown(); progress.countDown();
}, "Game Window", "", Priorities.NORMAL, TaskImportance.REQUIRED, "Assets")); }, "Game Window", "", Priorities.NORMAL, TaskImportance.REQUIRED, "Assets", "Progress Window"));
taskWorker.work(startStatusLatch); taskWorker.work(startStatusLatch);
try { try {

View File

@ -98,14 +98,6 @@ public class AssetsManager {
e.printStackTrace(); 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(); generateJarAssets();
assets.putAll(parseAssetsIndex(ASSETS_CLIENT_JAR_HASH)); assets.putAll(parseAssetsIndex(ASSETS_CLIENT_JAR_HASH));
latch.countDown(); latch.countDown();

View File

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