www.jpct.net

jPCT-AE - a 3d engine for Android => Bugs => Topic started by: SelimAbidin on December 29, 2015, 11:15:51 am

Title: Null Object Ref. com.threed.jpct.Object3D.oneTextureSet
Post by: SelimAbidin on December 29, 2015, 11:15:51 am
Hello

I have been developing an application and had a bug or normal behavior?


Scenario :

I use object pooling pattern in my application, so there are around 10 prepared Object3D instance in my ArrayList.

According to data i have from server, I remove all objects from world and add some objects from my ArrayList to world.  Everything works fine but time to time, i have this error.


E/AndroidRuntime: FATAL EXCEPTION: GLThread 122452
                                                                   Process: anka.ysa.com.test, PID: 28259
                                                                   java.lang.NullPointerException: Attempt to read from field 'boolean com.threed.jpct.Object3D.oneTextureSet' on a null object reference
                                                                       at com.threed.jpct.GLRenderer.drawVertexArray(GLRenderer.java:2355)
                                                                       at com.threed.jpct.World.draw(World.java:1419)
                                                                       at com.threed.jpct.World.draw(World.java:1102)
                                                                       at anka.ysa.com.test.TestRenderer.onDrawFrame(TestRenderer.java:48)
                                                                       at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1561)
                                                                       at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1278)


Sample Code :
Code: [Select]
ArrayList<Object3D> objects = new ArrayList<>();
    Object3D modelObject = null;
    public void addAndRemoveObjects()
    {
        while (objects.size() > 0)
        {
            scene.removeObject(objects.remove(0));
        }

        if (modelObject == null)modelObject = Primitives.getCube(10);

        for (int i = 0; i < 5; i++)
        {
           Object3D obj = new Object3D(modelObject);
           obj.translate(0,0,50);
           scene.addObject(obj);
           objects.add(obj);
        }
    }


Sample Application can be found at https://github.com/SelimAbidin/JPCTBugTest (https://github.com/SelimAbidin/JPCTBugTest)

Thanks for everything
Y.Selim Abidin




Title: Re: Null Object Ref. com.threed.jpct.Object3D.oneTextureSet
Post by: EgonOlsen on December 29, 2015, 01:34:12 pm
That's not a bug, it's...http://www.jpct.net/wiki/index.php?title=Thread_safety (http://www.jpct.net/wiki/index.php?title=Thread_safety)
Title: Re: Null Object Ref. com.threed.jpct.Object3D.oneTextureSet
Post by: SelimAbidin on December 30, 2015, 01:31:32 pm
Thanks for the answer and it reminded me RTFM  :-X