Offscreen Rendering exits suddenly

Found a bug? Post here.
neothemachine
Posts: 9
Joined: Tue 20. Mar 2012, 15:14

Offscreen Rendering exits suddenly

Post by neothemachine » Tue 20. Mar 2012, 15:32

Hi guys,

I tried to save an image with alpha without anti-aliasing but as soon as I hit save the viewer exits. I debugged the code and it's the line "canvas.display();" in JOGLOffscreenRenderer where it just exits.

It's probably difficult to help remotely, so how can I help to diagnose the fault?

Cheers
neo

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: Offscreen Rendering exits suddenly

Post by gunn » Wed 21. Mar 2012, 22:18

Neo,

Some suggestions, and questions:

Try rendering w/o alpha.

Does it print anything to stderr like "Tile size = ..." or "Allocating pbuffer" before exiting?

What kind of system are you rendering on? How big an image were you rendering?

If you have the source code (i.e., are a developer), you could try debugging the code. I'll tell you where to look if you tell me you want to try that.
jReality core developer

neothemachine
Posts: 9
Joined: Tue 20. Mar 2012, 15:14

Re: Offscreen Rendering exits suddenly

Post by neothemachine » Thu 22. Mar 2012, 11:08

Without alpha it prints the same to stderr.

My system is Ubuntu 11.10 64-bit. It's a laptop with integrated Intel HD 3000 graphics. The image size is 800x600.

I'm a developer, yes, and already tried to debug it, but I got stuck at canvas.display(); as this goes into jogl.jar where I didn't have the source now. Should I really go into jogl?

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: Offscreen Rendering exits suddenly

Post by gunn » Thu 22. Mar 2012, 12:36

Just to make sure we understand each other: Please confirm that you get the following printout to stderr (of course with different values) before the program exits:

Code: Select all

setting global aa factor to 4.0
Tile size x = 1212
Tile sizey = 900
Image size = 3636:2700
Allocating new pbuffer
Also, the call the canvas.display() where it bombs out is in de.jreality.jogl.JOGLOffscreenRenderer.renderOffscreen(int imageWidth, int imageHeight, double aa, GLAutoDrawable canvas), line 82.

When all the above is the case, then all I can think is that the Intel graphics is responsible. I'm not sure if any of the core developers use a machine with Intel graphics, so we wouldn't be aware if there were problems of this sort. Do you have access to another machine w/o Intel graphics were you can test this hypothesis?
jReality core developer

neothemachine
Posts: 9
Joined: Tue 20. Mar 2012, 15:14

Re: Offscreen Rendering exits suddenly

Post by neothemachine » Thu 22. Mar 2012, 14:46

Yes, I get that printout just before the program exits. And yes, it's line 82 of that file.

I can't test it on a different machine atm but at least one non-open-source framework (Bonzai Engine) does it without problems in JOGL.

With others like xith3d or Ardor3D I always run into some problems with JOGL so I use LWJGL where it works. I know that's not really helpful and I wonder why JOGL just exits without any exception or whatever. Quite frustrating...

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: Offscreen Rendering exits suddenly

Post by gunn » Thu 22. Mar 2012, 15:34

The offscreen rendering feature of the JOGL backend in jReality is one which I use quite a lot, so I'm a little surprised to hear that it's causing problems. I've even been working to improve the quality of the anti-aliasing, which is currently not working when you save the alpha channel.

You can perhaps get more information by using the debugging version of the GL class. To do this for the standard GLCanvas used in jReality, you need to run java with the vm option "-Djreality.jogl.debugGL=true". This will replace the GL instance with a compatible one for debugging. To do the same for the offscreen rendering, insert the following line of code directly before the call to canvas.display:

Code: Select all

		offscreenPBuffer.setGL(new DebugGL(offscreenPBuffer.getGL()));
jReality core developer

neothemachine
Posts: 9
Joined: Tue 20. Mar 2012, 15:14

Re: Offscreen Rendering exits suddenly

Post by neothemachine » Thu 22. Mar 2012, 17:20

I don't get any debug output with this option and line.

I downloaded the JOGL 1.1.1 source and tried to debug. After a bit of JOGL I now got back to jReality to line 377 of de.jreality.jogl.shader.DefaultPointShader:

Code: Select all

jr.globalGL.glCallList(dListProxy);
which exits and for which I don't have source code (why isn't it included in here??).

Edit: Well, and glCallList() is also a native method. End of road for me.

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: Offscreen Rendering exits suddenly

Post by gunn » Thu 22. Mar 2012, 21:47

If the offscreen rendering doesn't work, have you tried the screenshot option? It's accessible under the menu item "File->Export->Screenshot". As the name implies, it saves a copy of the current JOGL viewing component. That means you can't make save images larger than your display, whereas offscreen rendering can make arbitrarily large pictures (well 8k x 8k is about the max). I just tried out the screenshot option (for the first time!) and it looks pretty good, including anti-aliasing. And it's fast.

If you do get a chance to try your code on another machine I'd be interested to hear the results, just to know if the problem is hardware dependent.
jReality core developer

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: Offscreen Rendering exits suddenly

Post by gunn » Fri 23. Mar 2012, 21:53

One more idea on offscreen rendering: if the problem is in the display list (glCallList()) you can disable display lists by the following call to the top-level appearance ap:

Code: Select all

		ap.setAttribute(CommonAttributes.ANY_DISPLAY_LISTS, false);
jReality core developer

neothemachine
Posts: 9
Joined: Tue 20. Mar 2012, 15:14

Re: Offscreen Rendering exits suddenly

Post by neothemachine » Sat 24. Mar 2012, 21:00

The screenshot option works, but that's not really what I need in my case.

When I set the ANY_DISPLAY_LISTS attribute to false I get those nice lines:

Code: Select all

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f4b8c486fb4, pid=2942, tid=139962482689792
#
# JRE version: 7.0_147-b147
# Java VM: OpenJDK 64-Bit Server VM (21.0-b17 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea7 2.0
# Distribution: Ubuntu 11.10, package 7~b147-2.0-0ubuntu0.11.10.1
# Problematic frame:
# C  [i965_dri.so+0x31fb4]  intel_region_buffer+0x5a4
I wanted to attach the detailed crash log file the JVM produced but the forum says that .log and .txt are not allowed. I posted it as a gist instead. Maybe it helps, probably not.

Andre
Posts: 226
Joined: Fri 18. Sep 2009, 11:30

Re: Offscreen Rendering exits suddenly

Post by Andre » Sun 25. Mar 2012, 10:48

Hi neo,

do you get the same errors by using a different compiler like sun-java?

I'm just using sun-java, because Open-JDK in combination with Eclipse and jreality often causes errors.

HowTo install sun-java6-jdk:
http://www.gaggl.com/2011/10/installing ... ntu-11-10/

HowTo switch the compiler in eclipse (bit old and dusty, but should still work):
http://digimojo.blogspot.de/2007/09/cha ... tting.html

neothemachine
Posts: 9
Joined: Tue 20. Mar 2012, 15:14

Re: Offscreen Rendering exits suddenly

Post by neothemachine » Mon 26. Mar 2012, 10:23

I just tried it with sun's java but get the same error. I think it's important to mention that Bonzai Engine uses JOGL 2, so I guess whatever is wrong in JOGL 1.1.1 is fixed there.

Andre
Posts: 226
Joined: Fri 18. Sep 2009, 11:30

Re: Offscreen Rendering exits suddenly

Post by Andre » Mon 26. Mar 2012, 12:59

We have already a running hard coded jogl2-branch. It should be possible for you to check out this branch from the jreality svn-server. Just check out "branches" -> "jogamp" instead of "trunk"

Then you'll be able to check your code with a jogl2 version. But be aware, how I wrote this branch is hardcoded. So we just replaced the GL-Calls with GL2-Calls. Furthermore closing windows is now a bit buggy. We have just replaced the Linux64-bit libs. If you're using a different system so far you have to compile jogl/gluegen-rt first by your self and then you have to replace these libs in the classpath.

EDIT: if you need some advises for the last step (compiling jogl/gluegen-rt) I can help you a bit, just ask.

neothemachine
Posts: 9
Joined: Tue 20. Mar 2012, 15:14

Re: Offscreen Rendering exits suddenly

Post by neothemachine » Mon 26. Mar 2012, 17:18

Thanks Andre for pointing me to that. Unfortunately, it still just exits. I'll now try to get JOGL running in Ardor3D, there was just some stupid lib loading thing. And when I got offscreen rendering working there maybe we can together find a fix for jReality. That seems more realistic than figuring it out from Bonzai Engine without source code.

neothemachine
Posts: 9
Joined: Tue 20. Mar 2012, 15:14

Re: Offscreen Rendering exits suddenly

Post by neothemachine » Mon 26. Mar 2012, 20:01

Ok I got it working with Ardor3D and JOGL 1, so it must be a bug in jReality.

Let's see how Ardor3D does things...

The final image export is done with grabScreenContents() in com.ardor3d.renderer.jogl.JoglRenderer which basically just calls glReadPixels(). But I guess that's too late, as jReality is failing earlier when still rendering.

Sidenote -- The fact that jReality can render everything prior to exporting makes me believe that there's a bug in the offscreen rendering code. It seems that Ardor3D doesn't do anything special for doing screenshots, it just grabs the pixels with glReadPixels which obviously wouldn't fail in jReality either. It probably has some limitations (maybe AA doesn't work) which is why there is special code in jReality to improve this I guess (JOGLOffscreenRenderer etc.).

Hmmm, could it be that Ardor3D just works because it doesn't use PBuffers for this?


EDIT: I think I need some more things explained... Let me try, and you tell me if it's wrong. Ok, basically, offscreen rendering is used to render something without actually seeing it on the screen. This can be used to then insert this rendering as a texture in the main scene. Regarding taking screenshots: this must (?) be done with glReadPixels(), either reading from the main canvas or from the offscreen surface, right? So, I'm now wondering which dis-/advantages offscreen rendering has just for saving a rendering in a file. My assumption is that with offscreen rendering one has more control over image/display format. But is this really the case? Let's say I need 4xAA and picture size 4000x4000. With just taking a screenshot of the main canvas I would have to resize the window to 4000x4000, turn on 4xAA, and take the screenshot with glReadPixels. With offscreen rendering I could leave the window as is and render it invisibly. Does it make any difference if I don't care what's seen on the screen? (e.g. rendering on a server)

Thanks for taking the time :)
neo

Post Reply