Serialization problems -> nullPointerException in Object3D.transformVertices

Started by Vi_O, December 14, 2011, 04:35:22 PM

Previous topic - Next topic

Vi_O

Hello there,

I've been trying for a while to send simple 3D objects from a server to an android device using the DeSerializer class on the server and the Loader one on the client. The object is loaded on client-side but it does give me an NullPointerException for Object3D.transformVertices when trying to rendering the world and I don't know how to fix it...

Any suggestions ?

Here's the source code server-side : (exemple with a cube)



Object3D obj = Primitives.getCube(1);
obj.setTexture("rouge");
obj.build();
_deSerializer.serialize(obj, os, true);
                byte[] serializedObject = os.toByteArray();

                return serializedObject;



Then it goes all the way to the client...

Client-side :



                Object3D objLoader = Loader.loadSerializedObject(new ByteArrayInputStream(serializedObject));
                _world.addObject(objLoader);



Can't see what I've done wrong...

Thanks by advance for the help.

EgonOlsen


Vi_O

Here you are !



12-14 16:44:06.600: E/AndroidRuntime(18527): FATAL EXCEPTION: GLThread 10
12-14 16:44:06.600: E/AndroidRuntime(18527): java.lang.RuntimeException: [ 1323881046593 ] - ERROR: java.lang.NullPointerException
12-14 16:44:06.600: E/AndroidRuntime(18527): at com.threed.jpct.Object3D.transformVertices(Object3D.java:6316)
12-14 16:44:06.600: E/AndroidRuntime(18527): at com.threed.jpct.World.renderScene(World.java:1105)
12-14 16:44:06.600: E/AndroidRuntime(18527): at vo.ArKlee.e3d.JpctEngine.renderWorld(JpctEngine.java:170)
12-14 16:44:06.600: E/AndroidRuntime(18527): at vo.ArKlee.ArKleeActivity.onDrawFrame(ArKleeActivity.java:118)
12-14 16:44:06.600: E/AndroidRuntime(18527): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1431)
12-14 16:44:06.600: E/AndroidRuntime(18527): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1180)
12-14 16:44:06.600: E/AndroidRuntime(18527): at com.threed.jpct.Logger.log(Logger.java:189)
12-14 16:44:06.600: E/AndroidRuntime(18527): at com.threed.jpct.Logger.log(Logger.java:148)
12-14 16:44:06.600: E/AndroidRuntime(18527): at com.threed.jpct.World.renderScene(World.java:1121)
12-14 16:44:06.600: E/AndroidRuntime(18527): at vo.ArKlee.e3d.JpctEngine.renderWorld(JpctEngine.java:170)
12-14 16:44:06.600: E/AndroidRuntime(18527): at vo.ArKlee.ArKleeActivity.onDrawFrame(ArKleeActivity.java:118)
12-14 16:44:06.600: E/AndroidRuntime(18527): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1431)
12-14 16:44:06.600: E/AndroidRuntime(18527): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1180)



There is also some info log about the exception :



12-14 16:44:06.540: I/jPCT-AE(18527): OpenGL renderer initialized (using 2 texture stages)
12-14 16:44:06.580: I/jPCT-AE(18527): [ 1323881046592 ] - WARNING: There's a problem with the object list not being consistent during rendering. This is often caused by concurrent modification of jPCT objects on a thread different from the rendering thread!
12-14 16:44:06.590: I/jPCT-AE(18527): [ 1323881046593 ] - ERROR: java.lang.NullPointerException
12-14 16:44:06.590: I/jPCT-AE(18527): at com.threed.jpct.Object3D.transformVertices(Object3D.java:6316)
12-14 16:44:06.590: I/jPCT-AE(18527): at com.threed.jpct.World.renderScene(World.java:1105)
12-14 16:44:06.590: I/jPCT-AE(18527): at vo.ArKlee.e3d.JpctEngine.renderWorld(JpctEngine.java:170)
12-14 16:44:06.590: I/jPCT-AE(18527): at vo.ArKlee.ArKleeActivity.onDrawFrame(ArKleeActivity.java:118)
12-14 16:44:06.590: I/jPCT-AE(18527): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1431)
12-14 16:44:06.590: I/jPCT-AE(18527): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1180)
12-14 16:44:06.600: W/dalvikvm(18527): threadid=9: thread exiting with uncaught exception (group=0x4013a760)



Hope it helps, I know the error is not about the Loader class, but it occurs after I've tried to load serialized object from the server so I guess it is the problem.

Thanks for the quick reply

EgonOlsen

Actually, i've added this warning:

Quote
WARNING: There's a problem with the object list not being consistent during rendering. This is often caused by concurrent modification of jPCT objects on a thread different from the rendering thread!

because this is a common problem when somebody modifies the World or an Object3D from outside the rendering thread. Is there any chance that you are loading your object from the server in another thread in parallel to the rendering thread without proper synchronization?

Vi_O

Well, the 3DOBjects and world are loaded from the onSurfaceCreated of the OpenGLSurface Renderer.

Besides, by replacing :
Object3D objLoader = Loader.loadSerializedObject(new ByteArrayInputStream(serializedObject));
by
Object3D objLoader = Primitives.cube(1);

I've got a properly rendered cube and no warning...

I will check if the server/client thread doesn't interfere with the renderer somehow.

Vi_O

Ok, I've separated the two threads more clearly and now it works perfectly ^^
It wasn't about the serializer after all... My apologizes...

Thanks a lot for the quick response, that will be very helpful

Have a nice day !