LibGDX RayHandler: Cannot use offsets when Pixel Unpack Buffer Object is disabled - java

I recently updated my LibGDX library used in my game by using the LibGDX setup program to create a new project, then importing all of my classes, assets, etc into said new project. Everything went fine, the game runs and I can get in to the main menu. However, when I try advancing to the game where I have Box2DLights, I get an error thrown on the instantiation of my RayHandler. The RayHandler is instantiated like so:
rays = new RayHandler(world, Game.V_WIDTH/LIGHT_PIXEL_SIZE, Game.V_HEIGHT/LIGHT_PIXEL_SIZE);
This worked In the older version of the LibGDX libraries but now it throws Exception in thread "LWJGL Application" org.lwjgl.opengl.OpenGLException: Cannot use offsets when Pixel Unpack Buffer Object is disabled
The old version of LibGDX had GL20 and this one has GL30. I'm not sure if this is relevant because I have little to no knowledge of OpenGL.
Putting the line Gdx.gl.glBindBuffer(GL30.GL_PIXEL_UNPACK_BUFFER, 1); before the instantiation of my RayHandler changed the error to Exception in thread "LWJGL Application" java.lang.IllegalStateException: Frame buffer couldn't be constructed: incomplete attachment. Thrown on the line where my RayHandler is instantiated again.
The entire relevant stack trace for the first error is:
Exception in thread "LWJGL Application" org.lwjgl.opengl.OpenGLException: Cannot use offsets when Pixel Unpack Buffer Object is disabled
at org.lwjgl.opengl.GLChecks.ensureUnpackPBOenabled(GLChecks.java:125)
at org.lwjgl.opengl.GL11.glTexImage2D(GL11.java:2899)
at com.badlogic.gdx.backends.lwjgl.LwjglGL20.glTexImage2D(LwjglGL20.java:598)
at com.badlogic.gdx.graphics.glutils.GLOnlyTextureData.consumeCustomData(GLOnlyTextureData.java:78)
at com.badlogic.gdx.graphics.GLTexture.uploadImageData(GLTexture.java:270)
at com.badlogic.gdx.graphics.GLTexture.uploadImageData(GLTexture.java:257)
at com.badlogic.gdx.graphics.Texture.load(Texture.java:159)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:147)
at com.badlogic.gdx.graphics.Texture.<init>(Texture.java:142)
at com.badlogic.gdx.graphics.glutils.FrameBuffer.createTexture(FrameBuffer.java:81)
at com.badlogic.gdx.graphics.glutils.FrameBuffer.createTexture(FrameBuffer.java:42)
at com.badlogic.gdx.graphics.glutils.GLFrameBuffer.build(GLFrameBuffer.java:174)
at com.badlogic.gdx.graphics.glutils.FrameBuffer.<init>(FrameBuffer.java:75)
at com.badlogic.gdx.graphics.glutils.FrameBuffer.<init>(FrameBuffer.java:57)
at box2dLight.LightMap.<init>(LightMap.java:118)
at box2dLight.RayHandler.resizeFBO(RayHandler.java:143)
at box2dLight.RayHandler.<init>(RayHandler.java:132)

My question was answered by someone in the LibGDX Discord server. They shared this with me: https://github.com/libgdx/libgdx/issues/6407
Who knew that there could be a bug that isn't my fault?
Changing the GDX version from 1.9.14 to 1.9.15-SNAPSHOT fixed the issue.

Related

Fatal error when closing device with aclCloseDevice

I have implemented sounds to my application using OpenAL. Seemingly it is working fine until I close the application and trying to clean up every sound related object. Basically I have a cleanup method looks like this:
public void cleanup(){
//looping through sources and deleting them like this:
alSourceStop(id);
alDeleteSources(id);
//ids of sources and buffers are not the same they are in different classes
//looping through buffers and deleting them like this:
alDeleteBuffers(id);
//destroying context
alcDestroyContext(context);
//closing device
alcCloseDevice(device);
}
When I comment alcCloseDevice out I get a message like:
AL lib: (EE) alc_cleanup: 1 device not closed
If I leave it in its place:
A fatal error has been detected by the Java Runtime Environment ... Failed to write core dump ... and so on
I'm using LWJGL 3.1.0 on Windows 7 64bit os and all OpenGL and OpenAL related stuff is managed by one thread.
My set up looks like this:
device = alcOpenDevice((ByteBuffer)null);
ALCCapabilities caps = ALC.createCapabilities(device);
context = alcCreateContext(device, (IntBuffer)null);
alcMakeContextCurrent(context);
AL.createCapabilities(caps);
device and context are created without problem.
Creating buffer like this:
id = alGenBuffers();
try(STBVorbisInfo info = STBVorbisInfo.malloc()){
ShortBuffer buffer = /*decoding ogg here without problem*/
alBufferData(id, info.channels() == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16, buffer, info.sample_rate());
}
Also set up source and listener but I don't believe that would have any impact on it, without actually creating any source and listener closing device result in error.
Call, parse, and output alGetError() after each of your openAL calls in close method. This may shed light on what is failing.
Try dequeuing all buffers from a source before deleting your buffers. alSourcei(sourceID, AL_BUFFER, null);

What to do for memory related exception while working with NLP Stanford?

I am trying to run the Class : Word2VecSentimentRNN from the following link:
https://github.com/deeplearning4j/dl4j-examples/blob/master/dl4j-examples/src/main/java/org/deeplearning4j/examples/recurrent/word2vecsentiment/Word2VecSentimentRNN.java
The example is big one, hence given link of the example here.
Also I have downloaded the Sample vector file from the following link:
https://github.com/mmihaltz/word2vec-GoogleNews-vectors
I am getting the following error:
Exception in thread "main" java.lang.OutOfMemoryError: Cannot allocate 3103474 + 3600000000 bytes (> Pointer.maxBytes)
at org.bytedeco.javacpp.Pointer.deallocator(Pointer.java:484)
at org.bytedeco.javacpp.Pointer.init(Pointer.java:118)
at org.bytedeco.javacpp.FloatPointer.allocateArray(Native Method)
at org.bytedeco.javacpp.FloatPointer.<init>(FloatPointer.java:68)
at org.nd4j.linalg.api.buffer.BaseDataBuffer.<init>(BaseDataBuffer.java:457)
at org.nd4j.linalg.api.buffer.FloatBuffer.<init>(FloatBuffer.java:57)
at org.nd4j.linalg.api.buffer.factory.DefaultDataBufferFactory.createFloat(DefaultDataBufferFactory.java:238)
at org.nd4j.linalg.factory.Nd4j.createBuffer(Nd4j.java:1201)
at org.nd4j.linalg.factory.Nd4j.createBuffer(Nd4j.java:1176)
at org.nd4j.linalg.api.ndarray.BaseNDArray.<init>(BaseNDArray.java:230)
at org.nd4j.linalg.cpu.nativecpu.NDArray.<init>(NDArray.java:111)
at org.nd4j.linalg.cpu.nativecpu.CpuNDArrayFactory.create(CpuNDArrayFactory.java:247)
at org.nd4j.linalg.factory.Nd4j.create(Nd4j.java:4261)
at org.nd4j.linalg.factory.Nd4j.create(Nd4j.java:4227)
at org.nd4j.linalg.factory.Nd4j.create(Nd4j.java:3501)
at org.deeplearning4j.models.embeddings.loader.WordVectorSerializer.readBinaryModel(WordVectorSerializer.java:219)
at org.deeplearning4j.models.embeddings.loader.WordVectorSerializer.loadGoogleModel(WordVectorSerializer.java:118)
at com.nyu.sentimentanalysis.core.Word2VecSentimentRNN.run(Word2VecSentimentRNN.java:77)
I have tried to launch the application with the parameters -Xmx2g and -Xms2g. Even changed the values from time to time to check if it helps or work.
Kindly let me know what should I do. Getting locked up here.
I had this problem running standard Word2vec code and system dies after a while with OutOfMemory.
Following settings worked for me for sustaining long term load on production for DL4J/ND4J based app using Word2vec pre-trained model
java -Xmx2G -Dorg.bytedeco.javacpp.maxbytes=6G -Dorg.bytedeco.javacpp.maxphysicalbytes=6G

JavaFX - Media("File://derp") terminates with exception: MEDIA_INNACCESSIBLE

I'm trying to get a simple mp3 to run while my program runs, through this:
Media med = new Media("file://C:/Users/hariklia-elsa/workspace/PokerApp/src/intro.mp3");
MediaPlayer mPlayer = new MediaPlayer(med);
mPlayer.play();
But I'm running into problems. Running the program terminates with exception Exception in thread "main" MediaException: MEDIA_INACCESSIBLE : C, with reference to the first line of the code segment above, the one calling the Media() constructor.
I've had no previous experience with javafx or playing media in code, would anyone have any idea on why it would deem the file inaccessible? Am I doing anything simple incorrectly?
The file is, of course, fine. I can open it in a myriad different media players and it's fine.
This way it will work:
Media med = new Media("file:///C:/Users/hariklia-elsa/workspace/PokerApp/src/intro.mp3");
Note 3 slashes after file:.
Here is why: https://superuser.com/questions/352133/what-is-the-reason-that-file-urls-start-with-three-slashes-file-etc

Exception breakpoint occurred at EventDispatchThread.java

we are getting this error at the end of running application. I search in google buti don't know what cause this error and what this means. What to do and how to solve it?
i even don't know what raise this exception...
Exception breakpoint occurred at line 145 of EventDispatchThread.java.
java.lang.NullPointerException:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at oracle.jbo.uicli.jui.JUTableBinding$JUTableModel$2.run(JUTableBinding.java:1209)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Don't know what kind of searches you have performed on Google. I would suggest looking up each error (or rather each class where error occurs). Starting from the beginning as subsequent errors may be a due to error propagation. Two searches for EventDispatchThread and JUTableBinding.java may provide some insight at what went wrong.
http://www.docjar.org/docs/api/java/awt/EventDispatchThread.html
It seems that this class deals with AWT components ("takes events off the EventQueue and dispatches them to the appropriate AWT components")
For the JUTableBinding.java there are quite a few pages that say about NullPointerException
https://forums.oracle.com/forums/thread.jspa?threadID=515213
https://forums.oracle.com/forums/thread.jspa?threadID=2343921
https://kr.forums.oracle.com/forums/thread.jspa?threadID=503593
Some of them say that the problem may be with jdk version (seems 1.6 and above throw errors). I would assume that may be the case. Try to recompile using earlier versions of jdk and check whether error is still there. If it is not this then we will investigate further.
"I've looked into the code and found out that JUTableBinding.JUTableModel calls
mScrollUnit = control.getScrollableUnitIncrement(null,
SwingConstants.VERTICAL, 0);
(Line 947)
This was okay in Java 5, since JTable's getScrollableUnitIncrement just returned the row height."
"I changed the line to:
mScrollUnit = control.getScrollableUnitIncrement(
control.getVisibleRect(), SwingConstants.VERTICAL, 0);
and everything works fine on Java 6..."
Hope it helps.

When creating a custom Toolkit, why does createFrame fail on OSX?

We are trying to extend the UISpec4j testing framework to display the user interface when running tests. So we have a custom toolkit that wraps around the native toolkit for the relevant platform. We managed to get everything working well on windows XP, however when testing our changes on OSX, our extension of createFrame appears to behave oddly:
public FramePeer createFrame(Frame target) {
FramePeer resultc = new UISpecFramePeer(target);
//super.createFrame(target);
return resultc;
}
Essentially with the above, we want to create a UISpecFramePeer as an interception class... So that UISpec4j can interrogate what is happening within the UI. But in our changes, we also want to display the UI. So we attempt this by creating a frame using the native toolkit and wrapping it in the UISpecFramePeer (not shown in the code above).
When we run the above code, the tests run (as we expect) but obviously nothing is displayed. However, when we include super.createFrame(target). We get the following exception:
SEVERE: Application class org.openshapa.OpenSHAPA failed to launch
java.lang.ClassCastException: org.uispec4j.interception.toolkit.UISpecFramePeer
at apple.awt.CWindow$8.convertJComponentToTarget(CWindow.java:236)
at apple.awt.CWindow$8.convertJComponentToTarget(CWindow.java:233)
at apple.awt.ClientPropertyApplicator.attachAndApplyClientProperties(ClientPropertyApplicator.java:24)
at apple.awt.CWindow$1.propertyChange(CWindow.java:190)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:333)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:341)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:270)
at java.awt.Component.firePropertyChange(Component.java:7277)
at javax.swing.JComponent.addNotify(JComponent.java:4479)
at javax.swing.JRootPane.addNotify(JRootPane.java:680)
at java.awt.Container.addNotify(Container.java:2544)
at java.awt.Window.addNotify(Window.java:467)
at java.awt.Frame.addNotify(Frame.java:501)
at java.awt.Window.pack(Window.java:485)
at org.jdesktop.application.SingleFrameApplication.initRootPaneContainer(SingleFrameApplication.java:216)
at org.jdesktop.application.SingleFrameApplication.show(SingleFrameApplication.java:463)
at org.openshapa.OpenSHAPA.startup(OpenSHAPA.java:444)
at org.jdesktop.application.Application$1.run(Application.java:171)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Exception in thread "AWT-EventQueue-2" java.lang.Error: Application class org.openshapa.OpenSHAPA failed to launch
at org.jdesktop.application.Application$1.run(Application.java:177)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Caused by: java.lang.ClassCastException: org.uispec4j.interception.toolkit.UISpecFramePeer
at apple.awt.CWindow$8.convertJComponentToTarget(CWindow.java:236)
at apple.awt.CWindow$8.convertJComponentToTarget(CWindow.java:233)
at apple.awt.ClientPropertyApplicator.attachAndApplyClientProperties(ClientPropertyApplicator.java:24)
at apple.awt.CWindow$1.propertyChange(CWindow.java:190)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:333)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:341)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:270)
at java.awt.Component.firePropertyChange(Component.java:7277)
at javax.swing.JComponent.addNotify(JComponent.java:4479)
at javax.swing.JRootPane.addNotify(JRootPane.java:680)
at java.awt.Container.addNotify(Container.java:2544)
at java.awt.Window.addNotify(Window.java:467)
at java.awt.Frame.addNotify(Frame.java:501)
at java.awt.Window.pack(Window.java:485)
at org.jdesktop.application.SingleFrameApplication.initRootPaneContainer(SingleFrameApplication.java:216)
at org.jdesktop.application.SingleFrameApplication.show(SingleFrameApplication.java:463)
at org.openshapa.OpenSHAPA.startup(OpenSHAPA.java:444)
at org.jdesktop.application.Application$1.run(Application.java:171)
... 7 more
Why would simply using the native toolkit to create a frame (but not return it) create an exception, when it would otherwise behaves as normal when the super.createFrame is commented?
I havent worked on OSX, but the same problem would occur on Windows too and the reason would be this:
When you do super.createFrame(), you are essentially creating the native peer which ends up trying to show and hence addNotify methods are called. Now inside there are lot of methods that directly cast the peer to WFramePeer(this is incase of Windows, OSX it may be CWindowPeer or whatever), hence the ClassCastException. In your case, my guess is, the class CWindow is trying to cast your UISpecFramePeer to WFramePeer(or CFramePeer or whatever). Just check the CWindow code by decompiling and check. Please don't forget to post your findings.

Categories