jPCT-AE - a 3d engine for Android > Bugs

ArrayIndexOutOfBoundsException when loading from InputStream


I'm using the same *.obj file once from the server as an InputStream  and once as a local file packaged into the apk
I get ArrayIndexOutOfBoundsException only when using InputStream.

Help plz.

// Create and set 3D Object from local file works fine
objet3d = Object3D.mergeAll(Loader.loadOBJ(getResources().openRawResource(R.raw.scan_resul), null, 1f));

// Create and set 3D Object from input stream generates ArrayIndexOutOfBoundsException
InputStream ip = new ByteArrayInputStream(;
                try {
                        objet3d = Object3D.mergeAll(Loader.loadOBJ(ip, null, 1f));
                } catch (IOException e) {

java.lang.ArrayIndexOutOfBoundsException: length=2608; index=2608
                                                                         at com.threed.jpct.Loader.createOBJObject(
                                                                         at com.threed.jpct.Loader.loadOBJ(
                                                                         at com.threed.jpct.Loader.loadOBJ(
                                                                         at com.akka.AirCobotMQTT.activity.Visualisation3DReleaseActivity$MyRenderer.onSurfaceChanged(
                                                                         at android.opengl.GLSurfaceView$GLThread.guardedRun(
                                                                         at android.opengl.GLSurfaceView$

That's strange. As far as loading goes, there should be no difference between the two ways. Are you sure that really is an exact representation of the actual file's content?

Does this happen for any file or for just one in particular?

yes they are the some .
I tried more than one .obj file and get the some exception.

In fact the first issue happens because I use the inputstream wich made from a byte[] passed by an Intent
when I save it as file on the phone storage and load it again, it's loaded successfully.

Can you provide me with a simple example (code and model) that shows the problem? I can't reproduce this.


[0] Message Index

Go to full version