Hello Guest

pbuffer.isBufferLost() throws IllegalStateException

  • 3 Replies
  • 6144 Views
*

Offline Momoko_Fan

  • *
  • 38
  • jME3 lead developer
pbuffer.isBufferLost() throws IllegalStateException
« on: November 20, 2011, 00:04:12 »
This one is a little weird, here's the trace:

Code: [Select]
java.lang.IllegalStateException: The Drawable has no context available.
at org.lwjgl.opengl.DrawableGL.checkDestroyed(DrawableGL.java:152)
at org.lwjgl.opengl.Pbuffer.isBufferLost(Pbuffer.java:249)
at com.jme3.system.lwjgl.LwjglOffscreenBuffer.runLoop(LwjglOffscreenBuffer.java:113)
at com.jme3.system.lwjgl.LwjglOffscreenBuffer.run(LwjglOffscreenBuffer.java:147)
[catch] at java.lang.Thread.run(Thread.java:722)

The relevant code is this:
Code: [Select]
if (pbuffer.isBufferLost()){
            pbuffer.destroy();
            try{
                pbuffer = new Pbuffer(width, height, pixelFormat, null);
                pbuffer.makeCurrent();
            }catch (LWJGLException ex){
                listener.handleError("Failed to restore pbuffer content", ex);
            }
        }
As you can see there's really no chance for this code to happen if the pbuffer is destroyed, since it is immediately recreated afterwards.

It seems like this might be a bug? What do you think?

EDIT:
Here's the original post:
http://jmonkeyengine.org/groups/android/forum/topic/cant-install-android-support/#post-151579
There are other additional errors after it, might help understand the issue.
« Last Edit: November 20, 2011, 00:12:27 by Momoko_Fan »

*

Offline spasi

  • *****
  • 2242
    • WebHotelier
Re: [BUG] pbuffer.isBufferLost() throws IllegalStateException
« Reply #1 on: November 21, 2011, 11:38:05 »
AFAICT, the pbuffer was never created in the first place. See this one:

Code: [Select]
org.lwjgl.LWJGLException: Could not create Pbuffer
at org.lwjgl.opengl.WindowsPbufferPeerInfo.nCreate(Native Method)
at org.lwjgl.opengl.WindowsPbufferPeerInfo.(WindowsPbufferPeerInfo.java:47)
at org.lwjgl.opengl.WindowsDisplay.createPbuffer(WindowsDisplay.java:663)
at org.lwjgl.opengl.Pbuffer.createPbuffer(Pbuffer.java:234)
at org.lwjgl.opengl.Pbuffer.(Pbuffer.java:219)
at org.lwjgl.opengl.Pbuffer.(Pbuffer.java:190)
at org.lwjgl.opengl.Pbuffer.(Pbuffer.java:166)
[catch] at com.jme3.system.lwjgl.LwjglOffscreenBuffer.runLoop(LwjglOffscreenBuffer.java:116)
at com.jme3.system.lwjgl.LwjglOffscreenBuffer.run(LwjglOffscreenBuffer.java:147)
at java.lang.Thread.run(Thread.java:722)

The pbuffer being lost is not the same as being destroyed. You cannot call .isBufferLost on a destroyed, or (in this case) never created, pbuffer.

*

Offline Momoko_Fan

  • *
  • 38
  • jME3 lead developer
Re: [BUG] pbuffer.isBufferLost() throws IllegalStateException
« Reply #2 on: November 23, 2011, 04:59:59 »
That makes no sense. If I create a pbuffer with new Pbuffer() then it is created, if I call pbuffer.destroy() the pbuffer is destroyed. How can there exist a never created pbuffer that I can call isBufferLost() on?
Also the buffer can never be in a destroyed state, because in each instance where I destroy the pbuffer, I recreate it again.
Perhaps I am missing something obvious but I don't see it

*

Offline spasi

  • *****
  • 2242
    • WebHotelier
Re: [BUG] pbuffer.isBufferLost() throws IllegalStateException
« Reply #3 on: November 23, 2011, 08:26:53 »
This is what I think is happening:

- The original pbuffer was created successfully.
- At some point, .isBufferLost() returns true.
- You destroy the original pbuffer.
- You create another pbuffer, but an exception is thrown and the pbuffer variable continues to reference the original pbuffer.
- The next time .isBufferLost() is called on a destroyed pbuffer, so you get that exception.

Indeed, my previous reply wasn't accurate.