Skia Graphics Library as a renderer in Processing

I’ve just developed a small library to enable you to use Google’s Open Source Skia Graphics Library (via Skija) as a rendering engine for Processing.

README, a basic example and .jars here:

Because Skija targets JOGL (amongst other graphics back-ends) which is also used by Processing’s P2D and P3D modes, it’s possible to get Skija to render into the OPENGL window (sketch) that Processing creates. Though the code to do this isn’t much, it’s not straightforward, so this library eases that.

9 Likes

Hi, I’m trying to use your library but I don’t find the order of files where I need to download your .jar. in my library sketchbook. If I understand well it only works with Processing 4 ? Thanks

You mean the location where you put the .jar?

Processing 3’s IDE (PDE) is bundled w/ Java 8:

@matheplica Yeah, so if you’re using the Processing IDE, it will only work with Processing 4; it works with Processing 3 if you’re using Processing as a library in another IDE.

1 Like

Thanks. I’m mean the location and name of folder(s) to put the .jar in my librairies folder

You can simply drag-and-drop the jar onto the Processing IDE.

1 Like

I try it but I’ve got this error in P4:

No library found for org.jetbrains.skija
The type org.jetbrains.skija.Canvas cannot be resolved. It is indirectly referenced from required .class files
java.lang.reflect.InvocationTargetException

I’m guessing you’re using the 5KB version which doesn’t include the skija dependency.

Either use the other version (easier), or download skijia as .jar and drag-and-drop that onto Processing too.

1 Like

Ok, I try the other .jar and now I’ve got this error :

java.lang.RuntimeException: java.lang.UnsupportedClassVersionError: micycle/processingSkia/SkiaCanvas has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

That suggests Processing is running in Java 8 – are you certainly using Processing 4?

If so,

1 Like

With P4 I’ve got this error now : An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.jogamp.common.os.NativeLibrary
After google It’s seem that is a bug of P4Version

Kinda, it’s an warning (not an error) thrown by the JOGL library – the sketch should still run fine.

On my computer It’s an error but I need this line in settings to can run P2D mode :

System.setProperty("jogl.disable.openglcore", "true");

Ok, I tried on another computer and I have the same error, it’s maybe linux.
Here is the full message :

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.jogamp.common.os.NativeLibrary$3 (file:/home/math/artCode/sketchProcessing/skia/code/processing-skia-1.0.jar) to method java.lang.ClassLoader.findLibrary(java.lang.String)
WARNING: Please consider reporting this to the maintainers of com.jogamp.common.os.NativeLibrary$3
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
java.lang.RuntimeException: java.lang.ExceptionInInitializerError
	at processing.opengl.PSurfaceJOGL$2.run(PSurfaceJOGL.java:412)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.ExceptionInInitializerError
	at micycle.processingSkia.SkiaCanvas.<init>(SkiaCanvas.java:68)
	at micycle.processingSkia.SkiaCanvas.getSkiaCanvas(SkiaCanvas.java:42)
	at skia.setup(skia.java:199)
	at processing.core.PApplet.handleDraw(PApplet.java:2401)
	at processing.opengl.PSurfaceJOGL$DrawListener.display(PSurfaceJOGL.java:866)
	at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:692)
	at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:674)
	at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:443)
	at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293)
	at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147)
	at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:759)
	at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:81)
	at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:452)
	at com.jogamp.opengl.util.FPSAnimator$MainTask.run(FPSAnimator.java:178)
	at java.base/java.util.TimerThread.mainLoop(Timer.java:556)
	at java.base/java.util.TimerThread.run(Timer.java:506)
Caused by: java.lang.IllegalArgumentException: Library file libskija.so not found in /
	at org.jetbrains.skija.impl.Library._extract(Library.java:48)
	at org.jetbrains.skija.impl.Library.load(Library.java:32)
	at org.jetbrains.skija.impl.Library.staticLoad(Library.java:15)
	at org.jetbrains.skija.BackendRenderTarget.<clinit>(BackendRenderTarget.java:7)
	... 16 more
RuntimeException: java.lang.ExceptionInInitializerError
java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
	at processing.app.contrib.ToolContribution.<init>(ToolContribution.java:66)
	at processing.app.contrib.ToolContribution.load(ToolContribution.java:41)
	at processing.app.contrib.ToolContribution.loadAll(ToolContribution.java:104)
	at processing.app.Base.getInstalledContribs(Base.java:956)
	at processing.app.Base.getInstalledContribsInfo(Base.java:964)
	at processing.app.contrib.ContributionListing$1.run(ContributionListing.java:385)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.lang.NoClassDefFoundError: processing/app/Editor
	at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
	at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166)
	at java.base/java.lang.Class.getDeclaredMethod(Class.java:2473)
	at java.desktop/java.awt.Component.isCoalesceEventsOverriden(Component.java:6320)
	at java.desktop/java.awt.Component$3.run(Component.java:6274)
	at java.desktop/java.awt.Component$3.run(Component.java:6272)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.desktop/java.awt.Component.checkCoalescing(Component.java:6271)
	at java.desktop/java.awt.Component.<init>(Component.java:6240)
	at java.desktop/java.awt.Container.<init>(Container.java:296)
	at java.desktop/java.awt.Window.<init>(Window.java:547)
	at java.desktop/java.awt.Frame.<init>(Frame.java:423)
	at java.desktop/java.awt.Frame.<init>(Frame.java:388)
	at java.desktop/javax.swing.JFrame.<init>(JFrame.java:180)
	at Shader.tool.ShaderTool.<init>(Unknown Source)
	... 11 more
Caused by: java.lang.ClassNotFoundException: processing.app.Editor
	at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	... 26 more

Aye, it’ll be linux, as the version with dependencies includes Skija Windows version only.

Hi, did I understand correctly that it won’t start on mac OS?

It can do… You’ll just need to download Skija for mac yourself, as I’ve only produced a jar bundled with windows Skija version so far.

I’ve just added linux and mac .jars. Can someone test whether they work?

Tested on Linux (Ubuntu mate 20.10) with Processing 4 and the example works.
I just rename the folder “processingSkia”, create a library folder within and put .jar rename processingSkia.jar.
Thanks, it’s just missing help file to learn who to use it.