Do any one encounter Scene graph is not properly updated for rendering?

Do any one encounter this exceptions when called this method in updateModelBound(); in interface method?

And help me in finding ways to use enqueue or mutex lock or any multithreading mechanism, to update or refresh JME fragment view in SimpleApplicationClass, in to order to update vertices (x,y,z,w) of a mesh dynamically.

com.jme3.app.AndroidHarnessFragment: SEVERE Exception thrown in Thread[GLThread 22021,5,main]
java.lang.IllegalStateException: Scene graph is not properly updated for rendering.
State was changed after rootNode.updateGeometricState() call.
Make sure you do not modify the scene from another thread!
Problem spatial name: Root Node
at com.jme3.scene.Spatial.checkCulling(Spatial.java:361)
at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:717)
at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:710)
at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1096)
at com.jme3.renderer.RenderManager.render(RenderManager.java:1158)
at com.jme3.app.SimpleApplication.update(SimpleApplication.java:272)
at com.jme3.app.AndroidHarnessFragment.update(AndroidHarnessFragment.java:577)
at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:348)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1591)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1286)

Which part about enqueing is unclear?

1 Like

You can only ever update anything in the jME scene graph from the render thread - you can’t use locks or any other multithreading mechanism.

Your best bet is to do modifications to the scenegraph from the update() method of a Control or an AppState, but if you really need to update the scenegraph from another thread’s control flow then you must use enqueue():

app.enqueue(() -> {

    //... scene graph modifying code here

});

Note that the enqueue() method does not run the update code immediately - it takes the Runnable you pass it and runs it on the main render thread on its next update/render pass.

3 Likes

Hmm , seems you are updating your scene graph from the UI thread, use

app.enqueue(new Runnable(){
public void run(){
//Code 
}
}); 

as suggested above .

& If you want to update the android UI from a jme thread or GLES thread :

appCompatActivity.runOnUiThread(()->{
//Code 
});

Use code blocks to display stack traces or code snippets :