From 3cfe7dca229da5833960250e44a7f802d102bbac Mon Sep 17 00:00:00 2001 From: Johan Vos Date: Fri, 19 Jul 2019 14:37:05 +0200 Subject: [PATCH 1/2] initialize service in the FX AppThread --- .../com/gluonhq/attach/display/impl/IOSDisplayService.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/display/src/main/java/com/gluonhq/attach/display/impl/IOSDisplayService.java b/modules/display/src/main/java/com/gluonhq/attach/display/impl/IOSDisplayService.java index f33abd0b..512fe0cc 100644 --- a/modules/display/src/main/java/com/gluonhq/attach/display/impl/IOSDisplayService.java +++ b/modules/display/src/main/java/com/gluonhq/attach/display/impl/IOSDisplayService.java @@ -40,7 +40,7 @@ public class IOSDisplayService implements DisplayService { static { System.loadLibrary("Display"); - initDisplay(); + Platform.runLater(() -> initDisplay()); } private static ReadOnlyObjectWrapper notch; @@ -121,4 +121,4 @@ private static void notifyDisplay(String o) { Platform.runLater(() -> notch.setValue(d)); } } -} \ No newline at end of file +} From 91e8cb24bf494809374c84077ab8e83cbe6396ee Mon Sep 17 00:00:00 2001 From: Johan Vos Date: Fri, 19 Jul 2019 14:54:59 +0200 Subject: [PATCH 2/2] use env provided by init --- modules/display/src/main/native/ios/Display.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/display/src/main/native/ios/Display.m b/modules/display/src/main/native/ios/Display.m index 93600ef1..e95855bb 100644 --- a/modules/display/src/main/native/ios/Display.m +++ b/modules/display/src/main/native/ios/Display.m @@ -53,13 +53,14 @@ bool iPhoneX; JNIEXPORT void JNICALL Java_com_gluonhq_attach_display_impl_IOSDisplayService_initDisplay -(JNIEnv *env, jclass jClass) +(JNIEnv *myenv, jclass jClass) { if (DisplayInited) { return; } DisplayInited = 1; + env = myenv; mat_jDisplayServiceClass = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "com/gluonhq/attach/display/impl/IOSDisplayService")); mat_jDisplayService_notifyDisplay = (*env)->GetStaticMethodID(env, mat_jDisplayServiceClass, "notifyDisplay", "(Ljava/lang/String;)V"); @@ -211,4 +212,4 @@ -(void)OrientationDidChange:(NSNotification*)notification sendNotch(); } -@end \ No newline at end of file +@end