-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Since JRuby-9.0.0.0 changes to classloaders are failing ruby-processing #3152
Comments
could you be more specific, please. version 9.0.0.0.rc2 did revert the changes regarding the CLI interface of jruby putting its dynamic classloader into Thread.currentThread.contextClassLoader. BTW jruby-9k is not 2.2 compliant |
I think my updating overlapped your response. With ruby-processing I still need load to natives to classpath (with latest SNAPSHOT), which I found conflicts with previous loading (jruby-1.7.**). So I did a hack to only load binaries that way for jruby-9.0.0.0, but this leaves me with incompatability. I'm not worried about 2.2 compliance nice to use some 2.1 stuff though. |
could you point me to the hack you are using for loading binaries with jruby-9k ? |
Here is is the hack see line 197 for my crude detection of jruby version (note we could arrive here from mri ruby and mostly do). |
thanx. is this the piece of code which works with jruby-1.7.* but not with jruby-9k https://github.com/jashkenas/ruby-processing/blob/master/lib/ruby-processing/library_loader.rb#L68 or is it https://github.com/jashkenas/ruby-processing/blob/master/lib/ruby-processing/library_loader.rb#L62 ? any sample jar or so file which I can use for an isolated test ? |
Oh my god I thought I was going mad for bit, lots of things working that previously had not, including video capture, so thumbs up for reversal of classloader. In summary the major problem now appears to be the need to load the native OPENGL binaries into the java classpath for jruby-9.0.0.0 (this is needed for any sketch using processing P2D or P3D modes but not the default java_mode) so any test will need to emulate a P2D or P3D sketch. Simple P2D and P3D sketches also run OK. However when I try and include my arcball library for example (a jruby extension), then we get this failure:- Java::JavaLang::RuntimeException
org.jruby.exceptions.RaiseException: (NameError) cannot load Java class processing.arcball.Arcball
com.jogamp.common.util.awt.AWTEDTExecutor.invoke(AWTEDTExecutor.java:58)
jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(AWTThreadingPlugin.java:103)
jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread(ThreadingImpl.java:206)
javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:172)
javax.media.opengl.Threading.invoke(Threading.java:191)
javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:541)
processing.opengl.PJOGL.requestDraw(PJOGL.java:688)
processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:1651)
processing.core.PApplet.run(PApplet.java:2256)
java.lang.Thread.run(Thread.java:745) Or say for example we try and run a video capture sketch with P2D (OPENGL rendering) Java::JavaLang::RuntimeException
org.jruby.exceptions.RaiseException: (NameError) Capture not found in packages processing.video; last error: cannot link Java class processing.video.Capture, probable missing dependency: org/gstreamer/elements/BufferDataAppSink$Listener
com.jogamp.common.util.awt.AWTEDTExecutor.invoke(AWTEDTExecutor.java:58)
jogamp.opengl.awt.AWTThreadingPlugin.invokeOnOpenGLThread(AWTThreadingPlugin.java:103)
jogamp.opengl.ThreadingImpl.invokeOnOpenGLThread(ThreadingImpl.java:206)
javax.media.opengl.Threading.invokeOnOpenGLThread(Threading.java:172)
javax.media.opengl.Threading.invoke(Threading.java:191)
javax.media.opengl.awt.GLCanvas.display(GLCanvas.java:541)
processing.opengl.PJOGL.requestDraw(PJOGL.java:688)
processing.opengl.PGraphicsOpenGL.requestDraw(PGraphicsOpenGL.java:1651)
processing.core.PApplet.run(PApplet.java:2256)
java.lang.Thread.run(Thread.java:745) the same sketch works fine and dandy if we use Java2D rendering, that is OK for this sketch but won't allow us to do GLSL filtering for example. Problem is creating a suitable test, although I think possibly related errors have been reported for Swing apps? |
@mkristian OK here is the test https://github.com/monkstone/animationloop which illustrates the problem of loading my ArcBall extension. I have not done any fancy automation I'm afraid you just need to edit runner.rb to test the permutations (runner is required for adding jars to classpath). Also I realise now that my HACK added all the processing core jars to the classpath (my filter wasn't working because I was using tap) not just the binaries (but this was probably required anyway). |
@monkstone thanx for the repo - I am looking what I can find now |
@monkstone this is what I found so far to get your sketch.rb working: https://gist.github.com/mkristian/9ce9eece566c1ac03301 there is still some strange things going on and I think overall the code should work with jruby-1.7 as well jruby-9k as is. please note the public init method on Rarcball which I needed to add to avoid such errors https://gist.github.com/mkristian/9ce9eece566c1ac03301#file-error - @enebo any idea why this inner class can not access this package private static init method ? |
As an added note to @mkristian question. We realized this behavior for @JRubyMethod has always existed and we are only seeing it due to the other issues associated with loading. I do not think it is a bad idea for us to recommend public but we should probably fix this in both 1.7.x and 9k.x |
@mkristian that seems to solve that one now, it looks as though I will need to look at the other loading error, which might not be so simple to model (and fix). That is the loading of the video library jars that work fine when sketch is of the Java2D type but fails when the sketch is of OPENGL type. |
@monkstone the fact that you can just run 'sketch.rb' without the runner with jruby-1.7.x is still enough "example" to see what is going wrong with "requiring" jars in 9k. once this is fixed (hopefully soon) then we can look into the further problems of yours. |
@monkstone the current master can run sketch.rb as is and I think this is a good starting point to look into your other sketches. thanx again for repo - it was very helpful |
Excellent @mkristian that seems to be problem solved as far as I can tell, the classpath issue had put me off creating a version of JRubyArt where sketches run without a runner (for jruby) but that is a possibility again, and in the future ruby-processing also could be updated to use jruby-9.0.0.0. |
JRuby is losing the magic that let ruby-processing just work:-
To make ruby-processing work it is important that ruby and java classes can be added somewhat dynamically (including those with native binaries), the recent changes to the class loaders in JRuby-9.0.0.0 are making it all but impossible to combine say video libraries (incorporating gstreamer and the like) and graphics (OPENGL). In some ways this is a continuation the issue that I reported earlier #3036 which can be fixed for simple cases by loading the jars onto the java classpath. Now if there were a new way of doing this, but incompatible with the old way I would be very interested as I am trying to create a new version of ruby-processing JRubyArt. Here is what I currently have to do add video library to JRubyArt (this is hard coded in the app and OK for core libraries.
previously with ruby-processing we were able to add the jars from ruby and in our library _loader used the following hack to load the native binaries (even when not in a jar)
The text was updated successfully, but these errors were encountered: