JetBrains / skija

Java bindings for Skia
Apache License 2.0
2.63k stars 128 forks source link

bitmap example crashes #86

Closed tonsky closed 3 years ago

tonsky commented 3 years ago

Yes launching shadow jar from ITerm lead to

Unhandled exception Type=Segmentation error vmState=0x00040000 J9Generic_Signal_Number=00000018 Signal_Number=0000000b Error_Value=00000000 Signal_Code=00000001 Handler1=000000000A895340 Handler2=0000000006668C80 InaccessibleAddress=0000000000000000 RDI=000000000C980A00 RSI=0000000000000000 RAX=0000000000000404 RBX=0000000000000000 RCX=0000000000000410 RDX=0000000000000000 R8=0000000000000000 R9=0000000000099454 R10=00007FA11700E058 R11=00000000476D1344 R12=0000000000000000 R13=0000000000000000 R14=000000000C980A00 R15=0000000000000000 RIP=000000000A89DDE0 GS=0000 FS=0000 RSP=000070000957DE00 RFlags=0000000000010246 CS=002B RBP=000070000957DEA0 ERR=0000000000000004 TRAPNO=000000040000000E CPU=0000000000040000 FAULTVADDR=0000000000000000 XMM0 0000000000000000 (f: 0.000000, d: 0.000000e+00) XMM1 0000000000000000 (f: 0.000000, d: 0.000000e+00) XMM2 000e1781000e1781 (f: 923521.000000, d: 1.959708e-308) XMM3 0000000000000000 (f: 0.000000, d: 0.000000e+00) XMM4 0000000000000000 (f: 0.000000, d: 0.000000e+00) XMM5 0000000000170000 (f: 1507328.000000, d: 7.447190e-318) XMM6 3fc29552f81ff523 (f: 4162843904.000000, d: 1.451820e-01) XMM7 402e7f9c1e980fa9 (f: 513281952.000000, d: 1.524924e+01) XMM8 0000000000000000 (f: 0.000000, d: 0.000000e+00) XMM9 0000000000000000 (f: 0.000000, d: 0.000000e+00) XMM10 0000000000000006 (f: 6.000000, d: 2.964394e-323) XMM11 0000000000000008 (f: 8.000000, d: 3.952525e-323) XMM12 0000000000000000 (f: 0.000000, d: 0.000000e+00) XMM13 0000000000000000 (f: 0.000000, d: 0.000000e+00) XMM14 0000000000000000 (f: 0.000000, d: 0.000000e+00) XMM15 0000000000000000 (f: 0.000000, d: 0.000000e+00)

Originally posted by @Solido in https://github.com/JetBrains/skija/issues/53#issuecomment-755774385

tonsky commented 3 years ago

@Solido can you share more details on this? OS version? java -version? Hardware? Do other examples (lwjgl) work?

Solido commented 3 years ago

Hi @tonsky Here are some infos Thank you

15.0.1.j9-adpt BigSur 11.1 Macbook pro Intel Skija 0.6.58 Kotlin 1.4.21

Every app OK when launcher from an env with graphic context Only tried my app and default example but my guess is graphical context is missing in shell Did not try on linux or remote ssh call / server side Will work from an intelliJ Shell

tonsky commented 3 years ago

Sounds exactly like my setup. I even downloaded iTerm

Screenshot 2021-01-07 at 16 07 08
tonsky commented 3 years ago

@Solido try using HotSpot instead of J9? I managed to make J9 fail during java compilation (!), maybe HotSpot will work better for you?

Solido commented 3 years ago

Interesting suggestion !

I got one step further but crash again even trying multiple SDK using SDK Man

Tried a very standart OpenJDK Runtime Environment AdoptOpenJDK (11.0.9.1+1) (build 11.0.9.1+1)

What java version are you using ?

Thanks !

tonsky commented 3 years ago
adoptopenjdk-15-openj9.jdk
adoptopenjdk-15.jdk
amazon-corretto-11.jdk
jdk-11.0.6.jdk
jdk-13.jdk
jdk-14.jdk
jdk-15.jdk
jdk1.8.0_241.jdk

The only ones that don’t work are the first one (15 + J9 instead of HotSpot) and last one (jdk 8, not supposed to).

Solido commented 3 years ago

I have tried them all and still manage to crash so it should be smth different.

Do you think that the shadow jar
id("com.github.johnrengelman.shadow") version "6.1.0" can corrupt something ?

Or we have a different installation somehow ? You seems able to launch the script I am not without manual install of the dynlib Could it be that your shell find it but it fails if it is only inside the fat shadow jar ?

Also I checked by opening the jar the lib is there but my question is related to the classloader maybe not finding it due to conf ?

tonsky commented 3 years ago

Are you able to generate bitmap by simply running examples/bitmap/script/run.sh as it is?

Best, Nikita

On 10 Jan 2021, at 01:18, Robert Felker notifications@github.com wrote:

 I have tried them all and still manage to crash so it should be smth different.

Do you think that the shadow jar id("com.github.johnrengelman.shadow") version "6.1.0" can corrupt something ?

Or we have a different installation somewhere ? You seems able to launch the script I am not without manual install of the dynlib Could it be that your shell find it but it fails inside shadow jar ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

Solido commented 3 years ago

Nope I can not because I removed the manual installation of skia and only rely on the jar from gradle. My supposition is that it works on your command line because you have the full install !?

% ./script/run.sh
Exception in thread "main" java.lang.ExceptionInInitializerError
    at org.jetbrains.skija.examples.bitmap.RenderToBitmap.main(RenderToBitmap.java:7)
Caused by: java.lang.IllegalArgumentException: Library file libskija.dylib not found in /
    at org.jetbrains.skija.impl.Library._extract(Library.java:77)
    at org.jetbrains.skija.impl.Library.load(Library.java:39)
    at org.jetbrains.skija.impl.Library.staticLoad(Library.java:16)
    at org.jetbrains.skija.Surface.<clinit>(Surface.java:9)
    ... 1 more
tonsky commented 3 years ago

Let’s include everything except raw JVM out of the equation. Try this please (in examples/bitmap directory):

java -version
rm -rf target
mkdir -p target/classes
curl --fail --location --show-error --silent -o target/skija-shared-0.6.61.jar https://packages.jetbrains.team/maven/p/skija/maven/org/jetbrains/skija/skija-shared/0.6.61/skija-shared-0.6.61.jar
curl --fail --location --show-error --silent -o target/skija-macos-0.6.61.jar https://packages.jetbrains.team/maven/p/skija/maven/org/jetbrains/skija/skija-macos/0.6.61/skija-macos-0.6.61.jar
javac -d target/classes -encoding UTF8 --release 11 --class-path target/skija-shared-0.6.61.jar src/*.java
java --class-path target/classes:target/skija-shared-0.6.61.jar:target/skija-macos-0.6.61.jar org.jetbrains.skija.examples.bitmap.RenderToBitmap
ls -lah output.png
Solido commented 3 years ago

Thank you very much @tonsky !

It worked & based on your snippet I was able to build a script to replace the shadow jar that failed to expand.

Sorry it was more java cp hell than Skija related ...

tonsky commented 3 years ago

Glad it’s resolved!