Updating version of Renjin supported in SciJava

Hi, This is very similar to the problem @twagner described in '17, except I’ve been replacing with v3.5b76. The motivation for the changed version is support for Renjin grDevices and ggplot2, etc (for plot types not support elsewhere). It is working well in a plugin of mine-slow vs JFreeChart but quick enough.

As suggest by @ctrueden in the above mentioned post, I looked at the pom @ scijava/ scripting-renjin to submit a PR, but it wasn’t clear to me where to update the version. Assistance with the best path forward would be appreciated. Thanks.

1 Like

@winfrees Updating the version of Renjin in SciJava et al. would be great. Did you try changing the version constant here? It’s just updating the <renjin-script.version> value. Does the code still build with passing tests? Does all your Renjin-related code still work? Do you think we have enough unit tests to cover it?

@akbertram Does Renjin in the meantime supports a custom plot device as availabe in JavaGD?

I quite wonder that ggplot should be slow if it is an image rendering only.

If I plot with Rserve (e.g., as image) it is quite fast. Definitely faster as a R plot device with a scalabe canvas.

If I plot with the default R device (Java stream without Rserve) it is much slower (certainly caused by the scalable vector rendering).

It would be awesome if the version would be updated and extensions such as ggplot2 be included or easily addable.

I tried bumping to a newer version of renjin-script-engine here:

… but had to disable a failing assertion to make the test pass.

I didn’t try yet whether the built jar file works fine in a Fiji installation, maybe someone else wants to try it with my changes?!

When running the included template script Compute_Quantile.R on the Blobs sample image, I get the following exceptions in the console:

org.renjin.eval.EvalException: Exception initializing compiled GNU R library class org.renjin.grDevices.grDevices
	at org.renjin.primitives.packaging.DllInfo.initialize(DllInfo.java:141)
	at org.renjin.primitives.packaging.Namespace.loadDynamicLibrary(Namespace.java:383)
	at org.renjin.primitives.packaging.Namespace.importDynamicLibrary(Namespace.java:296)
	at org.renjin.primitives.packaging.Namespace.initImports(Namespace.java:274)
	at org.renjin.primitives.packaging.NamespaceRegistry.load(NamespaceRegistry.java:175)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:156)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:130)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:114)
	at org.renjin.primitives.packaging.Namespace.initImports(Namespace.java:211)
	at org.renjin.primitives.packaging.NamespaceRegistry.load(NamespaceRegistry.java:175)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:156)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:130)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:114)
	at org.renjin.primitives.packaging.Namespace.initImports(Namespace.java:211)
	at org.renjin.primitives.packaging.NamespaceRegistry.load(NamespaceRegistry.java:175)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:156)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:130)
	at org.renjin.primitives.io.serialization.SessionReadContext.findNamespace(SessionReadContext.java:55)
	at org.renjin.primitives.io.serialization.RDataReader.readNamespace(RDataReader.java:508)
	at org.renjin.primitives.io.serialization.RDataReader.readExp(RDataReader.java:177)
	at org.renjin.primitives.io.serialization.RDataReader.readTag(RDataReader.java:420)
	at org.renjin.primitives.io.serialization.RDataReader.readClosure(RDataReader.java:252)
	at org.renjin.primitives.io.serialization.RDataReader.readExp(RDataReader.java:185)
	at org.renjin.primitives.io.serialization.RDataReader.readFile(RDataReader.java:81)
	at org.renjin.packaging.LazyLoadFrame.readVersion2(LazyLoadFrame.java:85)
	at org.renjin.packaging.LazyLoadFrame.load(LazyLoadFrame.java:46)
	at org.renjin.primitives.packaging.FileBasedPackage.loadSymbols(FileBasedPackage.java:49)
	at org.renjin.primitives.packaging.Namespace.populateNamespace(Namespace.java:174)
	at org.renjin.primitives.packaging.NamespaceRegistry.load(NamespaceRegistry.java:169)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:156)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:130)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:114)
	at org.renjin.primitives.packaging.Packages.library(Packages.java:39)
	at org.renjin.primitives.R$primitive$library.doApply(R$primitive$library.java:68)
	at org.renjin.primitives.R$primitive$library.applyPromised(R$primitive$library.java:33)
	at org.renjin.sexp.BuiltinFunction.apply(BuiltinFunction.java:100)
	at org.renjin.primitives.special.InternalFunction.apply(InternalFunction.java:46)
	at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
	at org.renjin.eval.Context.evaluate(Context.java:282)
	at org.renjin.primitives.special.BeginFunction.apply(BeginFunction.java:39)
	at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
	at org.renjin.sexp.Closure.applyPromised(Closure.java:200)
	at org.renjin.sexp.Closure.apply(Closure.java:133)
	at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
	at org.renjin.eval.Context.evaluate(Context.java:282)
	at org.renjin.eval.Context.evaluate(Context.java:209)
	at org.renjin.eval.SessionBuilder.build(SessionBuilder.java:187)
	at org.renjin.script.RenjinScriptEngineFactory.getScriptEngine(RenjinScriptEngineFactory.java:110)
	at org.renjin.script.RenjinScriptEngineFactory.getScriptEngine(RenjinScriptEngineFactory.java:30)
	at org.scijava.script.AdaptedScriptLanguage.getScriptEngine(AdaptedScriptLanguage.java:137)
	at org.scijava.script.ScriptModule.getEngine(ScriptModule.java:105)
	at org.scijava.script.ScriptModule.run(ScriptModule.java:126)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:163)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:124)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:63)
	at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:225)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoSuchMethodError: org.renjin.gcc.runtime.Ptr.setPointer(Lorg/renjin/gcc/runtime/Ptr;)V
	at org.renjin.grDevices.Context.colors$$ColorDataBase$$init(Unknown Source)
	at org.renjin.grDevices.Context.<init>(Unknown Source)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	at java.lang.Class.newInstance(Class.java:442)
	at org.renjin.eval.Session.getSingleton(Session.java:198)
	at org.renjin.eval.Context.getSingleton(Context.java:286)
	at org.renjin.grDevices.Context.current(Unknown Source)
	at org.renjin.grDevices.Context.get__main-devices$R_Devices(Unknown Source)
	at org.renjin.grDevices.main_devices__.Rf_InitGraphics(main-devices.c:514)
	at org.renjin.grDevices.init__.R_init_grDevices(init.c:140)
	at org.renjin.grDevices.grDevices.R_init_grDevices(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.renjin.primitives.packaging.DllInfo.initialize(DllInfo.java:137)
	... 59 more
org.renjin.eval.EvalException: Exception initializing compiled GNU R library class org.renjin.graphics.graphics
	at org.renjin.primitives.packaging.DllInfo.initialize(DllInfo.java:141)
	at org.renjin.primitives.packaging.Namespace.loadDynamicLibrary(Namespace.java:383)
	at org.renjin.primitives.packaging.Namespace.importDynamicLibrary(Namespace.java:296)
	at org.renjin.primitives.packaging.Namespace.initImports(Namespace.java:274)
	at org.renjin.primitives.packaging.NamespaceRegistry.load(NamespaceRegistry.java:175)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:156)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:130)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:114)
	at org.renjin.primitives.packaging.Namespace.initImports(Namespace.java:211)
	at org.renjin.primitives.packaging.NamespaceRegistry.load(NamespaceRegistry.java:175)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:156)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:130)
	at org.renjin.primitives.io.serialization.SessionReadContext.findNamespace(SessionReadContext.java:55)
	at org.renjin.primitives.io.serialization.RDataReader.readNamespace(RDataReader.java:508)
	at org.renjin.primitives.io.serialization.RDataReader.readExp(RDataReader.java:177)
	at org.renjin.primitives.io.serialization.RDataReader.readTag(RDataReader.java:420)
	at org.renjin.primitives.io.serialization.RDataReader.readClosure(RDataReader.java:252)
	at org.renjin.primitives.io.serialization.RDataReader.readExp(RDataReader.java:185)
	at org.renjin.primitives.io.serialization.RDataReader.readFile(RDataReader.java:81)
	at org.renjin.packaging.LazyLoadFrame.readVersion2(LazyLoadFrame.java:85)
	at org.renjin.packaging.LazyLoadFrame.load(LazyLoadFrame.java:46)
	at org.renjin.primitives.packaging.FileBasedPackage.loadSymbols(FileBasedPackage.java:49)
	at org.renjin.primitives.packaging.Namespace.populateNamespace(Namespace.java:174)
	at org.renjin.primitives.packaging.NamespaceRegistry.load(NamespaceRegistry.java:169)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:156)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:130)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:114)
	at org.renjin.primitives.packaging.Packages.library(Packages.java:39)
	at org.renjin.primitives.R$primitive$library.doApply(R$primitive$library.java:68)
	at org.renjin.primitives.R$primitive$library.applyPromised(R$primitive$library.java:33)
	at org.renjin.sexp.BuiltinFunction.apply(BuiltinFunction.java:100)
	at org.renjin.primitives.special.InternalFunction.apply(InternalFunction.java:46)
	at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
	at org.renjin.eval.Context.evaluate(Context.java:282)
	at org.renjin.primitives.special.BeginFunction.apply(BeginFunction.java:39)
	at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
	at org.renjin.sexp.Closure.applyPromised(Closure.java:200)
	at org.renjin.sexp.Closure.apply(Closure.java:133)
	at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
	at org.renjin.eval.Context.evaluate(Context.java:282)
	at org.renjin.eval.Context.evaluate(Context.java:209)
	at org.renjin.eval.SessionBuilder.build(SessionBuilder.java:187)
	at org.renjin.script.RenjinScriptEngineFactory.getScriptEngine(RenjinScriptEngineFactory.java:110)
	at org.renjin.script.RenjinScriptEngineFactory.getScriptEngine(RenjinScriptEngineFactory.java:30)
	at org.scijava.script.AdaptedScriptLanguage.getScriptEngine(AdaptedScriptLanguage.java:137)
	at org.scijava.script.ScriptModule.getEngine(ScriptModule.java:105)
	at org.scijava.script.ScriptModule.run(ScriptModule.java:126)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:163)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:124)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:63)
	at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:225)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoSuchMethodError: org.renjin.gcc.runtime.BytePtr.of(I)Lorg/renjin/gcc/runtime/Ptr;
	at org.renjin.graphics.init__.R_init_graphics(init.c:87)
	at org.renjin.graphics.graphics.R_init_graphics(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.renjin.primitives.packaging.DllInfo.initialize(DllInfo.java:137)
	... 54 more
org.renjin.eval.EvalException: Exception initializing compiled GNU R library class org.renjin.stats.stats
	at org.renjin.primitives.packaging.DllInfo.initialize(DllInfo.java:141)
	at org.renjin.primitives.packaging.Namespace.loadDynamicLibrary(Namespace.java:383)
	at org.renjin.primitives.packaging.Namespace.importDynamicLibrary(Namespace.java:296)
	at org.renjin.primitives.packaging.Namespace.initImports(Namespace.java:274)
	at org.renjin.primitives.packaging.NamespaceRegistry.load(NamespaceRegistry.java:175)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:156)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:130)
	at org.renjin.primitives.io.serialization.SessionReadContext.findNamespace(SessionReadContext.java:55)
	at org.renjin.primitives.io.serialization.RDataReader.readNamespace(RDataReader.java:508)
	at org.renjin.primitives.io.serialization.RDataReader.readExp(RDataReader.java:177)
	at org.renjin.primitives.io.serialization.RDataReader.readTag(RDataReader.java:420)
	at org.renjin.primitives.io.serialization.RDataReader.readClosure(RDataReader.java:252)
	at org.renjin.primitives.io.serialization.RDataReader.readExp(RDataReader.java:185)
	at org.renjin.primitives.io.serialization.RDataReader.readFile(RDataReader.java:81)
	at org.renjin.packaging.LazyLoadFrame.readVersion2(LazyLoadFrame.java:85)
	at org.renjin.packaging.LazyLoadFrame.load(LazyLoadFrame.java:46)
	at org.renjin.primitives.packaging.FileBasedPackage.loadSymbols(FileBasedPackage.java:49)
	at org.renjin.primitives.packaging.Namespace.populateNamespace(Namespace.java:174)
	at org.renjin.primitives.packaging.NamespaceRegistry.load(NamespaceRegistry.java:169)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:156)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:130)
	at org.renjin.primitives.packaging.NamespaceRegistry.getNamespace(NamespaceRegistry.java:114)
	at org.renjin.primitives.packaging.Packages.library(Packages.java:39)
	at org.renjin.primitives.R$primitive$library.doApply(R$primitive$library.java:68)
	at org.renjin.primitives.R$primitive$library.applyPromised(R$primitive$library.java:33)
	at org.renjin.sexp.BuiltinFunction.apply(BuiltinFunction.java:100)
	at org.renjin.primitives.special.InternalFunction.apply(InternalFunction.java:46)
	at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
	at org.renjin.eval.Context.evaluate(Context.java:282)
	at org.renjin.primitives.special.BeginFunction.apply(BeginFunction.java:39)
	at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
	at org.renjin.sexp.Closure.applyPromised(Closure.java:200)
	at org.renjin.sexp.Closure.apply(Closure.java:133)
	at org.renjin.sexp.FunctionCall.eval(FunctionCall.java:80)
	at org.renjin.eval.Context.evaluate(Context.java:282)
	at org.renjin.eval.Context.evaluate(Context.java:209)
	at org.renjin.eval.SessionBuilder.build(SessionBuilder.java:187)
	at org.renjin.script.RenjinScriptEngineFactory.getScriptEngine(RenjinScriptEngineFactory.java:110)
	at org.renjin.script.RenjinScriptEngineFactory.getScriptEngine(RenjinScriptEngineFactory.java:30)
	at org.scijava.script.AdaptedScriptLanguage.getScriptEngine(AdaptedScriptLanguage.java:137)
	at org.scijava.script.ScriptModule.getEngine(ScriptModule.java:105)
	at org.scijava.script.ScriptModule.run(ScriptModule.java:126)
	at org.scijava.module.ModuleRunner.run(ModuleRunner.java:163)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:124)
	at org.scijava.module.ModuleRunner.call(ModuleRunner.java:63)
	at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:225)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NoSuchMethodError: org.renjin.gcc.runtime.Ptr.setPointer(Lorg/renjin/gcc/runtime/Ptr;)V
	at org.renjin.stats.init__.ExtEntries$$clinit(init.c)
	at org.renjin.stats.init__.<clinit>(init.c)
	at org.renjin.stats.stats.R_init_stats(Unknown Source)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.renjin.primitives.packaging.DllInfo.initialize(DllInfo.java:137)
	... 49 more

However, the computed results look fine:

1 32.0
2 64.0
3 208.0

(I didn’t try any ggplot2 functionality yet…)

Thanks, @imagejan. Does anyone on this thread have time and interest to dig a little deeper? I’d really like to be shipping the latest version of Renjin with Fiji—but we can’t update it until more thorough testing has been done, and ideally unit tests have been fleshed out a bit in scijava/scripting-renjin.