HumbleUI / Skija

Java bindings for Skia
Apache License 2.0
514 stars 34 forks source link

Typeface._nMakeFromName returns null on linux #49

Closed Glavo closed 1 year ago

Glavo commented 1 year ago

The fourteenth scene (Font Size) in the examples crashes. Here is the log:

glavo@W510 ~/P/Skija (linux-arm64) [1]> python3 ./examples/kwinit/script/run.py
Using Skia from /home/glavo/Projects/Skija/platform/Skia-m109-664500fa93-linux-Release-arm64
-- Configuring done
-- Generating done
-- Build files have been written to: /home/glavo/Projects/Skija/platform/target/linux-arm64/native
ninja: no work to do.
    Finished release [optimized + debuginfo] target(s) in 0.11s
2023-02-28T15:00:26.590149605Z [DEBUG] Loading /home/glavo/Projects/Skija/platform/target/linux-arm64/classes/io/github/humbleui/skija/linux/arm64/libskija.so
WARNING in native method: JNI call made with exception pending
        at noria.kwinit.impl.ExternalAPI.runEventLoop(Native Method)
        at noria.kwinit.impl.Main.run(Main.java:65)
        at noria.kwinit.impl.Main.main(Main.java:18)
Exception in thread "main" java.lang.RuntimeException: Can't wrap nullptr
        at io.github.humbleui.skija.impl.Native.<init>(Native.java:12)
        at io.github.humbleui.skija.impl.Managed.<init>(Managed.java:14)
        at io.github.humbleui.skija.impl.Managed.<init>(Managed.java:10)
        at io.github.humbleui.skija.impl.RefCnt.<init>(RefCnt.java:7)
        at io.github.humbleui.skija.Typeface.<init>(Typeface.java:393)
        at io.github.humbleui.skija.Typeface.makeFromName(Typeface.java:123)
        at io.github.humbleui.skija.examples.scenes.FontSizeScene.lambda$new$0(FontSizeScene.java:55)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
        at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:575)
        at java.base/java.util.stream.AbstractPipeline.evaluateToArrayNode(AbstractPipeline.java:260)
        at java.base/java.util.stream.ReferencePipeline.toArray(ReferencePipeline.java:616)
        at io.github.humbleui.skija.examples.scenes.FontSizeScene.<init>(FontSizeScene.java:59)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
        at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128)
        at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347)
        at java.base/java.lang.Class.newInstance(Class.java:645)
        at io.github.humbleui.skija.examples.scenes.Scenes.newScene(Scenes.java:73)
        at io.github.humbleui.skija.examples.scenes.Scenes.setScene(Scenes.java:89)
        at io.github.humbleui.skija.examples.scenes.Scenes.prevScene(Scenes.java:81)
        at noria.kwinit.impl.Main.onKeyDown(Main.java:172)
        at noria.kwinit.impl.Main.lambda$run$1(Main.java:84)
        at noria.kwinit.impl.ExternalAPI.runEventLoop(Native Method)
        at noria.kwinit.impl.Main.run(Main.java:65)
        at noria.kwinit.impl.Main.main(Main.java:18)
Traceback (most recent call last):
  File "/home/glavo/Projects/Skija/./examples/kwinit/script/run.py", line 59, in <module>
    sys.exit(main())
  File "/home/glavo/Projects/Skija/./examples/kwinit/script/run.py", line 44, in main
    subprocess.check_call([
  File "/usr/lib/python3.10/subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['java', '--class-path', 'target/classes:/home/glavo/.m2/repository/org/jetbrains/annotations/20.1.0/annotations-20.1.0.jar:/home/glavo/.m2/repository/org/projectlombok/lombok/1.18.22/lombok-1.18.22.jar:/home/glavo/.m2/repository/io/github/humbleui/types/0.2.0/types-0.2.0.jar:/home/glavo/.m2/repository/com/google/code/gson/gson/2.8.6/gson-2.8.6.jar:../../platform/target/linux-arm64/classes:../../shared/target/classes-java9:../../shared/target/classes', '-Djava.awt.headless=true', '-enableassertions', '-enablesystemassertions', '-Xcheck:jni', '-Dskija.logLevel=DEBUG', 'noria.kwinit.impl.Main']' returned non-zero exit status 1.
Glavo commented 1 year ago

I found it would crash on my x86 device as well.

Glavo commented 1 year ago

Well, it seems that there are no special problems on Linux ARM64, because these problems also occur on Linux x86-64.

tonsky commented 1 year ago

I guess Skia was lying in their docs about never returning null...

zp-1999 commented 2 months ago

I also encountered the same problem as you on Ubuntu arm64. How did you solve it?

tonsky commented 2 months ago

What do you mean exactly? Where is the problem occuring? And what is the problem?