javafxports / javafxmobile-plugin

A gradle plugin for building mobile applications in java.
BSD 3-Clause "New" or "Revised" License
42 stars 19 forks source link

Font usage fails on iOS #66

Open odbuser2 opened 6 years ago

odbuser2 commented 6 years ago

BLOCKER

org.javafxports:jfxmobile-plugin:2.0.24 iOS 11.40 OSX 10.13.5 XCode Version Version 9.4 (9F1027a) downConfig 3.8.0

Description Using javafx.scene.text.Font such as calling: Font.getFontFamilies();

Results in: non-fatal, couldn't load class named com/sun/javafx/font/t2k/T2KFactory Exception in Application start method QuantumRenderer: shutdown

Is this a gvm issue with the latest iOS? The same code was working on the previous version.

odbuser2 commented 6 years ago

PS this is a blocker b/c it hangs the App on iOS indefinitely when calling any Font method.

johanvos commented 6 years ago

is this specific to 11.4?

jperedadnr commented 6 years ago

I've upgraded to the latest versions:

Then I tried a simple template project, adding this line of code: Font.getFontNames().forEach(System.out::println);

And it works perfectly fine, printing all the fonts available.

Of course there is this printout (it always does):

non-fatal, couldn't load class named com/sun/javafx/font/t2k/T2KFactory

So there is nothing wrong with 'Font`.

In case you find Exception in Application start method QuantumRenderer: shutdown it seems there is an exception in your code that somehow is shallowed and not logged.

I'd suggest adding a try-catch (Throwable t) { t.printStacktrace(); } to your related code.

odbuser2 commented 6 years ago

Will do. It is now working on on one ipad and mac with the latest of everything but not on another with the same versions (different mac and different ipad). I had narrowed it down to any call with Font but did not put a try catch around it. I'll report back in the next day or so.

odbuser2 commented 6 years ago

Clarification This happening on an iPhone deployed from a Macbook Pro with everything updated (well except I haven't tried with org.javafxports:jfxmobile-plugin:2.0.25 which was just released). If I don't put a try catch around the first call to the Font class, the application will just hang. However, with the try catch it will continue and subsequent Font calls work.

Application Code

public void start(Stage stage) throws Exception {
    try {
        System.out.println(">Calling method on font");
        Font.getFamilies();
    } catch (Throwable t) {
        t.printStackTrace();
        System.out.println("<Failed to call method on Font");
    }
    System.out.println("Made it!");
}

Output

>Calling method on font
java.lang.NullPointerException
    at java.lang.Throwable.fillInStackTrace(Unknown Source)
    at java.lang.Throwable.<init>(Unknown Source)
    at java.lang.Exception.<init>(Unknown Source)
    at java.lang.RuntimeException.<init>(Unknown Source)
    at java.lang.NullPointerException.<init>(Unknown Source)
    at java.io.File.<init>(Unknown Source)
    at com.sun.javafx.font.PrismFontFactory.populateFontFileNameMapGeneric(Unknown Source)
    at com.sun.javafx.font.PrismFontFactory.getFullNameToFileMap(Unknown Source)
    at com.sun.javafx.font.PrismFontFactory.getFontFamilyNames(Unknown Source)
    at com.sun.javafx.font.PrismFontLoader.getFamilies(Unknown Source)
    at javafx.scene.text.Font.getFamilies(Unknown Source)
    at com.myapp.start(Unknown Source)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(Unknown Source)
    at com.sun.javafx.application.LauncherImpl$$Lambda$9.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$11(Unknown Source)
    at com.sun.javafx.application.PlatformImpl$$Lambda$10.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$9(Unknown Source)
    at com.sun.javafx.application.PlatformImpl$$Lambda$22.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
    at com.sun.javafx.application.PlatformImpl$$Lambda$9.run(Unknown Source)
<Failed to call method on Font
Made it!

Without the try catch the app hangs with a black screen on the phone and has the following output

>Calling method on font
NATIVELIBLOADER, loadLibraryInternal for javafx_font
[CL] LOADLIBRARY for name javafx_font and fromclass = class com.sun.glass.utils.NativeLibLoader
[JVDBG] ClassLoader.c, find builtinlib for libjavafx_font.dylib
[JVDBG] ClassLoader.c result of search a JniFunction for this = 0x106fe794c
NATIVELIBLOADER, I DID loadLibraryInternal for javafx_font
[JVDBG]StyleManager will invoke getResource with string com/sun/javafx/scene/control/skin/modena/modena.bss and skinPrefix = com/sun/javafx/scene/control/skin/
[JVDBG]StyleManager will invoke getResource with string com/sun/javafx/scene/control/skin/modena/modena.bss and parameter = modena/modena.bss!!!!!
UUUUTILS getResource will be called
YYYYTILS getResource will be called with modena/modena.bss!??
[JVDBG]StyleManager will invoke getResource with string com/sun/javafx/scene/control/skin/modena/modena.css and skinPrefix = com/sun/javafx/scene/control/skin/
[JVDBG]StyleManager will invoke getResource with string com/sun/javafx/scene/control/skin/modena/modena.css and parameter = modena/modena.css!!!!!
UUUUTILS getResource will be called
YYYYTILS getResource will be called with modena/modena.css!??
[JVDBG]StyleManager will invoke getResource with string com/sun/javafx/scene/control/skin/modena/touch.bss and skinPrefix = com/sun/javafx/scene/control/skin/
[JVDBG]StyleManager will invoke getResource with string com/sun/javafx/scene/control/skin/modena/touch.bss and parameter = modena/touch.bss!!!!!
UUUUTILS getResource will be called
YYYYTILS getResource will be called with modena/touch.bss!??
[JVDBG]StyleManager will invoke getResource with string com/sun/javafx/scene/control/skin/modena/touch.css and skinPrefix = com/sun/javafx/scene/control/skin/
[JVDBG]StyleManager will invoke getResource with string com/sun/javafx/scene/control/skin/modena/touch.css and parameter = modena/touch.css!!!!!
UUUUTILS getResource will be called
YYYYTILS getResource will be called with modena/touch.css!??
non-fatal, couldn't load class named com/sun/javafx/font/t2k/T2KFactory
Exception in Application start method
QuantumRenderer: shutdown
DetachThread 0x11423fc40
DONE DONE DONE
[JVDBG] VM started
DetachThread 0x11423fb60
odbuser2 commented 6 years ago

Same behavior with 2.0.25.

jperedadnr commented 6 years ago

I've tried Font.getFamilies() and it works just fine for me.

I'll suggest to clean your project:

And from time to time removing the ~/.gvm folder might help as well. You will have to run the AOT compiler again, but you will get rid of old compilations.

odbuser2 commented 6 years ago

Yes, I've tried that a few times with the same result.

jperedadnr commented 6 years ago

Then I don't think Font nor Font.getFamilies() have anything to do with the issue. If you find QuantumRenderer: shutdown usually it is because a NPE that throws an exception that is somehow swallowed. Adding printouts and try-catch (Throwable t) should give you a better clue.

jperedadnr commented 6 years ago

By the way, the new release of the plugin (2.0.27) should print the stacktrace, maybe you can give it a try?

odbuser2 commented 6 years ago

It is definitely failing when calling methods on Font. You may have missed the stacktrace I posted a few days back. I also tried 2.0.27 and it prints the exact same stacktrace. Also, as previously stated, if I put a try catch around it and then call Font.getFontFamilies() again, it works!

java.lang.NullPointerException
    at java.lang.Throwable.fillInStackTrace(Unknown Source)
    at java.lang.Throwable.<init>(Unknown Source)
    at java.lang.Exception.<init>(Unknown Source)
    at java.lang.RuntimeException.<init>(Unknown Source)
    at java.lang.NullPointerException.<init>(Unknown Source)
    at java.io.File.<init>(Unknown Source)
    at com.sun.javafx.font.PrismFontFactory.populateFontFileNameMapGeneric(Unknown Source)
    at com.sun.javafx.font.PrismFontFactory.getFullNameToFileMap(Unknown Source)
    at com.sun.javafx.font.PrismFontFactory.getFontFamilyNames(Unknown Source)
    at com.sun.javafx.font.PrismFontLoader.getFamilies(Unknown Source)
    at javafx.scene.text.Font.getFamilies(Unknown Source)
    at com.myapp.start(Unknown Source)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(Unknown Source)
    at com.sun.javafx.application.LauncherImpl$$Lambda$9.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$11(Unknown Source)
    at com.sun.javafx.application.PlatformImpl$$Lambda$10.run(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$9(Unknown Source)
    at com.sun.javafx.application.PlatformImpl$$Lambda$22.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Unknown Source)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(Unknown Source)
    at com.sun.javafx.application.PlatformImpl$$Lambda$9.run(Unknown Source)