IllegalArgumentException: object id must be greater than zero on GalaxyTab3

Hi guys,

I have a jme3 game running on android. It works properly on PC and on phone Star HD5000(Android 4.2.2 QuadCore Gpu: Mali 400-MP).
Today I tested it on Galaxy Tab 3 - 10.1", (Android 4.2.2 Cpu: Dual-core Gpu:PowerVR SGX544MP2)

Occasionally, about in five minutes I get the following error on the galaxy tab. I have checked the updateBufferData function and it does:

public void updateBufferData(VertexBuffer vb) {
        int bufId = vb.getId();
        boolean created = false;
        if (bufId == -1) {
            // create buffer
            GLES20.glGenBuffers(1, intBuf1);
            RendererUtil.checkGLError();

            bufId = intBuf1.get(0);
            vb.setId(bufId);
            objManager.registerObject(vb);
.....

Thus it seems that GLES20.glGenBuffers(1, intBuf1); fills the buffer with a 0 id. What could possibly lead to this behavior. I also wonder when glGenBuffers fills 0 as an id, why the objManager throws an exception. Also, strangely RendererUtil.checkGLError() did not print any errors.

I/InputDispatcher(17295): Delivering touch to: action: 0x1
W/dalvikvm(15225): threadid=11: thread exiting with uncaught exception (group=0x41ac5e10)
E/com.jme3.app.AndroidHarness(15225): SEVERE Exception thrown in Thread[GLThread 3534,5,main]
E/com.jme3.app.AndroidHarness(15225): java.lang.IllegalArgumentException: object id must be greater than zero
E/com.jme3.app.AndroidHarness(15225): 	at com.jme3.util.NativeObjectManager.registerObject(NativeObjectManager.java:104)
E/com.jme3.app.AndroidHarness(15225): 	at com.jme3.renderer.android.OGLESShaderRenderer.updateBufferData(OGLESShaderRenderer.java:1888)
E/com.jme3.app.AndroidHarness(15225): 	at com.jme3.renderer.android.OGLESShaderRenderer.setVertexAttrib(OGLESShaderRenderer.java:2006)
E/com.jme3.app.AndroidHarness(15225): 	at com.jme3.renderer.android.OGLESShaderRenderer.setVertexAttrib(OGLESShaderRenderer.java:2077)
E/com.jme3.app.AndroidHarness(15225): 	at com.jme3.renderer.android.OGLESShaderRenderer.renderMeshDefault(OGLESShaderRenderer.java:2317)
E/com.jme3.app.AndroidHarness(15225): 	at com.jme3.renderer.android.OGLESShaderRenderer.renderMesh(OGLESShaderRenderer.java:2358)
E/com.jme3.app.AndroidHarness(15225): 	at com.jme3.material.Material.render(Material.java:1119)
E/com.jme3.app.AndroidHarness(15225): 	at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:523)
E/com.jme3.app.AndroidHarness(15225): 	at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:322)
E/com.jme3.app.AndroidHarness(15225): 	at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:371)
E/com.jme3.app.AndroidHarness(15225): 	at com.jme3.renderer.RenderManager.renderViewPortQueues(RenderManager.java:788)
E/com.jme3.app.AndroidHarness(15225): 	at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:719)
E/com.jme3.app.AndroidHarness(15225): 	at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:983)
E/com.jme3.app.AndroidHarness(15225): 	at com.jme3.renderer.RenderManager.render(RenderManager.java:1035)
E/com.jme3.app.AndroidHarness(15225): 	at jmeutil.SimpleApp.update(SimpleApp.java:297)
E/com.jme3.app.AndroidHarness(15225): 	at mygame.Main.update(Main.java:176)
E/com.jme3.app.AndroidHarness(15225): 	at com.jme3.app.AndroidHarness.update(AndroidHarness.java:467)
E/com.jme3.app.AndroidHarness(15225): 	at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:349)
E/com.jme3.app.AndroidHarness(15225): 	at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1524)
E/com.jme3.app.AndroidHarness(15225): 	at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)
E/com.jme3.app.AndroidHarness(15225): 
D/dalvikvm(15225): Rejecting registerization due to div-int/lit8 v0, v3, (#2)

Thanks for you help.

I have seen this error before and can recreate it, but it’s over my head as how to fix it.

For me this usually happens when objects in the scene are being created and removed very quickly.

Is something similar happening in your logic?

Perhaps objects moving around at high speeds?

1 Like
@BigBob said: I have seen this error before and can recreate it, but it's over my head as how to fix it. For me this usually happens when objects in the scene are being created and removed very quickly. Is something similar happening in your logic? Perhaps objects moving around at high speeds?

Yes, I have a gui that attaches and detaches existing objects very quickly. Ill change the gui and see what happens. Thanks.

Edited: Apparently it was creating new objects every time due to a bug in my object pool.

after some searching on net I found someone say

Yes, it is completely valid to call glGenBuffers multiple times, as long as you call equal amounts of glDeleteBuffers at some point in the future.
I have checked the ids of the vertexbuffers that i kept attaching/detaching. I tested this on pc. Apparently, as I kept attacking/detaching their id’s began to increase. after few seconds of vertexbuffer.getid() returned value over 400000.

Also I observed that after some time of not using that gui, the id count drops.

Thus, it seems with certain speed of attaching/detaching objectscreating new and removing with updated vertex buffers, the id’s keep increasing.
I wonder if glDeleteBuffers is called when an object is detached. If it is then, it is strange that the id is not released immediately.

ps: this gui of is not yet finished thats why the numerous attaching/detaching,

Thanks @BigBob, it seems that fixes the issue.

1 Like

:stuck_out_tongue: Awesome!

Good to hear. I’ve added this to the All Things Android thread.

1 Like