Any oddities to keep in mind when using Disply.setParent() with a JFrame?

Started by Rene, November 10, 2010, 19:33:39

Previous topic - Next topic

Rene

Hi,

I have some problems with recent AMD/ATI drivers when using Display.setParent(). The native frame works fine.

The problem is that the driver sometimes crashes at seemingly random opengl function calls, though there are a few favorites: glBufferData, glGenMipMapsEXT(), and glTexImage2D(). Because of the randomness I was first thinking of a race condition, but it also happens when I step through the code. The crashes alway happen during the rendering of the first frame, if the first frame renders fine the application will work as expected.

The display is created on the main Thread, and all OpenGL calls are made from the main Thread. The JVM is launched with, among others, the options '-Dsun.java2d.noddraw=true -Dsun.awt.noerasebackground=true -Dsun.java2d.d3d=false -Dsun.java2d.opengl=false'. What's strange is that Fraps still reports D3D9 is being used, can this be caused by the aero desktop? If so, can the problem be caused by use of both D3D and OpenGL in the same application?

So, is there anything I need to keep in mind when using Display.setParent()? Thanks in advance.
When I am king, they shall not have bread and shelter only, but also teachings out of books, for a full belly is little worth where the mind is starved - Mark Twain

kappa

Quote from: Rene on November 10, 2010, 19:33:39
So, is there anything I need to keep in mind when using Display.setParent()? Thanks in advance.

Have a read of the tutorial on creating a basic lwjgl applet, although its mainly for applets but the idea's there should roughtly apply when using with a JFrame.

BatKid

I haven't had any problems with putting an env3d window inside a JFrame - in fact it has been working great.  However, I don't actually have an ATI graphics card so I'm not sure.  Which version of lwjgl are you using?  I know that if you use 2.2.2, it has some issues with ATI drivers.

If you like, you can launch my app at http://whalechat.com.  It is an app that uses Display.setParent(), with lots of swing components around it.  Open up the java console and see if you get any errors.
Projects: 
   Env3D (http://env3d.org): Learn Java in 3D
   WhaleChat (http://whalechat.com): A 3D social programming experiment

Rene

Quote from: kappa on November 10, 2010, 19:54:11
Have a read of the tutorial on creating a basic lwjgl applet, although its mainly for applets but the idea's there should roughtly apply when using with a JFrame.

I've taken a look at the example, and my canvas initialization code is quite similar. One significant difference was the point where the display is created: I did it in a HierarchyListener, while the example does it in addNotify(). Is there a reason for creating the display there?
Anyway, I've modified my code to create the display in addNotify() and I'm running some tests... I'll let you know if it crashes again.

Quote from: BatKid on November 10, 2010, 20:36:56
I haven't had any problems with putting an env3d window inside a JFrame - in fact it has been working great.  However, I don't actually have an ATI graphics card so I'm not sure.  Which version of lwjgl are you using?  I know that if you use 2.2.2, it has some issues with ATI drivers.

If you like, you can launch my app at http://whalchat.com.  It is an app that uses Display.setParent(), with lots of swing components around it.  Open up the java console and see if you get any errors.
I'm using a nightly build of LWJGL 2.5, so that should be fine. And only ATI cards have this problem, machines with NVidia cards haven't crashed once. Because this is going on for about six months now I'm quite sure they are fine ;)
Btw, I tried to open your link, but it appears to be broken.

EDIT:
Nope, still crashing
When I am king, they shall not have bread and shelter only, but also teachings out of books, for a full belly is little worth where the mind is starved - Mark Twain

kappa

looks like some sort of driver crash then, opengl and d3d in the same app? (sounds like a recipe for disaster on weak drivers).

BatKid

Sorry about the link, it was a typo (i fixed it now, you can also find the app in my sig).

Anyway, I assume that you are using the latest drivers?  Maybe a clean re-install (It worked for some people I think).
Projects: 
   Env3D (http://env3d.org): Learn Java in 3D
   WhaleChat (http://whalechat.com): A 3D social programming experiment

Rene

The D3D problem what my mistake. In the first post, I didn't mean to say Fraps, but GPU PerfStudio. In case you're unfamiliar with it, it's a tool used with AMD GPU's to optimize and debug 3D applications. It works by opening a 'server application' with your executable as argument. Obviously, the trouble with Java applications is that you need to start the Java executable with, in turn, your application as argument. To make things a little easier I created a shortcut containing all required arguments and settings to start my application, but I forgot to add the 'noD3D' parameters. After fixing the shortcut D3D doesn't show up anymore.

Sadly, this means the problem isn't caused by using D3D and OGL in the same application. If I can find the real culprit I'll post it here.
When I am king, they shall not have bread and shelter only, but also teachings out of books, for a full belly is little worth where the mind is starved - Mark Twain

princec


Rene

One thing that makes debugging hard is that the JVM itself doesn't crash, only the display driver. This means the driver will reset, and the application continues after the faulty call. Then it will hang indefinitely at nSwapBuffers().
When I am king, they shall not have bread and shelter only, but also teachings out of books, for a full belly is little worth where the mind is starved - Mark Twain