Interesting Exception (Resolved)

You expected right:

So you’re code with or without is basically no different.

Note: if it helps think about possible NaN issues remember that dividing by 0 is a very common way for that to happen.

This is the output during the exception? Or just random output?

The original exception indicated that there were only about 8 or 9 items in that bucket.

You really need to dump all of the geometry and not just your tiles.

    @Override
    public void update() {
        try {
            super.update();
        } catch (Exception e) {
            LOG.error("Something very bad happened!");
            LOG.error("Let's print the scene graph...");
            getRootNode().depthFirstTraversal(v -> LOG.error("Geometry " + v.getWorldTranslation() + " " + v.getWorldRotation() + " " + v.getName()));
            LOG.error("Camera location: " + getCamera().getLocation() + ", orientation: " + getCamera().getRotation());
        }
    }

There are tons of 3D objects in the scene graph when the exception happens. Shall I plot all geometries of all objects? I probably didn’t get what you suggest me todo. I do not operate anywhere in the code directly on Geometrics…

It just wasn’t clear if you were showing me a random frame’s output or the output from an exception.

Since the bounding shape is actually what is used for sorting, it would be better to print that.

…additionally, you should still log the exception because the index out of bounds number might give you a clue as to which bucket was at issue.

Oh I didn’t past the full log. It’s huge, just was looking for entries which look clearly different than the rest, so it is just a snap. And it is always this exception:

07:10:40,202 ERROR [Main] Something very bad happened!
java.lang.ArrayIndexOutOfBoundsException: 5
	at com.jme3.util.ListSort.sort(ListSort.java:231)
	at com.jme3.renderer.queue.GeometryList.sort(GeometryList.java:158)
	at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:262)
	at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:305)
	at com.jme3.renderer.RenderManager.renderViewPortQueues(RenderManager.java:877)
	at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:779)
	at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1108)
	at com.jme3.renderer.RenderManager.render(RenderManager.java:1158)
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:272)
	at ch.artificials.bubble.Main.update(Main.java:138)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)
	at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:197)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:232)
	at java.lang.Thread.run(Thread.java:748)
07:10:40,205 ERROR [Main] Let's print the scene graph...
07:10:40,205 ERROR [Main] Geometry World (0.0, 0.0, 0.0) (0.0, 0.0, 0.0, 1.0) null
07:10:40,206 ERROR [Main] Geometry Local (0.0, 0.0, 0.0) (0.0, 0.0, 0.0, 1.0) null
07:10:40,206 ERROR [Main] Geometry World (0.0, 0.0, 0.0) (0.0, 0.0, 0.0, 1.0) null
07:10:40,206 ERROR [Main] Geometry Local (0.0, 0.0, 0.0) (0.0, 0.0, 0.0, 1.0) null
07:10:40,206 ERROR [Main] Geometry World (0.0, 0.0, 0.0) (0.0, 0.0, 0.0, 1.0) null
07:10:40,206 ERROR [Main] Geometry Local (0.0, 0.0, 0.0) (0.0, 0.0, 0.0, 1.0) null
07:10:40,206 ERROR [Main] Geometry World (87.0, -17.0, -2.0) (0.0, 0.0, 0.0, 1.0) Cube.0501
...

Oh, what are those null name elements here? All the others have names…

Ah and how do I plot the bounding shape? What do you mean by that? Still new to the real stuff here :slight_smile:

log.info(geometry.getName() + " " + geometry.getWorldBound());
…or I don’t understand the question.

…whatever render bucket is failing to sort, I think it only has 10 or 11 items in it.

07:20:39,065 ERROR [Main] Geometry World BoundingBox [Center: (85.0, -17.0, -1.5)  xExtent: 0.5  yExtent: 0.5  zExtent: 0.0] Wall1
07:20:39,065 ERROR [Main] Geometry World BoundingBox [Center: (86.0, -17.0, -1.5)  xExtent: 0.5  yExtent: 0.5  zExtent: 0.0] Cube.0501
07:20:39,065 ERROR [Main] Geometry World BoundingBox [Center: (86.0, -17.0, -1.5)  xExtent: 0.5  yExtent: 0.5  zExtent: 0.0] Wall1
07:20:39,065 ERROR [Main] Geometry World BoundingBox [Center: (87.0, -17.0, -1.5)  xExtent: 0.5  yExtent: 0.5  zExtent: 0.0] Cube.0501
07:20:39,065 ERROR [Main] Geometry World BoundingBox [Center: (87.0, -17.0, -1.5)  xExtent: 0.5  yExtent: 0.5  zExtent: 0.0] Wall1
07:20:39,065 ERROR [Main] Geometry World BoundingBox [Center: (89.89454, -24.371004, 0.56120473)  xExtent: 0.10546381  yExtent: 0.114670075  zExtent: 0.087260425] Sphere.0061
07:20:39,065 ERROR [Main] Geometry World BoundingBox [Center: (89.89454, -24.371004, 0.56120473)  xExtent: 0.10546381  yExtent: 0.114670075  zExtent: 0.087260425] LeftArm
07:20:39,065 ERROR [Main] Geometry World BoundingBox [Center: (89.89454, -24.371004, -0.56120473)  xExtent: 0.10546381  yExtent: 0.114670075  zExtent: 0.087260425] Sphere.0041
07:20:39,065 ERROR [Main] Geometry World BoundingBox [Center: (89.89454, -24.371004, -0.56120473)  xExtent: 0.10546381  yExtent: 0.114670075  zExtent: 0.087260425] RightArm
07:20:39,071 ERROR [Main] Geometry World BoundingBox [Center: (90.00316, -24.353065, 3.8642999E-19)  xExtent: 0.4950413  yExtent: 0.10335459  zExtent: 0.49999982] Sphere1
07:20:39,071 ERROR [Main] Geometry World BoundingBox [Center: (90.0, -24.301388, 0.0)  xExtent: 0.49999985  yExtent: 0.051677294  zExtent: 0.4619395] Sphere2
07:20:39,071 ERROR [Main] Geometry World BoundingBox [Center: (90.0, -24.26462, 0.0)  xExtent: 0.49999985  yExtent: 0.01490962  zExtent: 0.49999982] Sphere3
07:20:39,071 ERROR [Main] Geometry World BoundingBox [Center: (90.0, -24.27953, 0.0)  xExtent: 0.4675664  yExtent: 0.0  zExtent: 0.46756637] Sphere4
07:20:39,071 ERROR [Main] Geometry World BoundingBox [Center: (90.0, -24.353065, 0.0)  xExtent: 0.5  yExtent: 0.10335541  zExtent: 0.49999982] Body
07:20:39,072 ERROR [Main] Geometry World BoundingBox [Center: (90.002014, -24.048258, 2.469101E-19)  xExtent: 0.46176147  yExtent: 0.28103605  zExtent: 0.46929386] Sphere.0031
07:20:39,072 ERROR [Main] Geometry World BoundingBox [Center: (90.00652, -23.865776, 7.98944E-19)  xExtent: 0.5178876  yExtent: 0.37282956  zExtent: 0.59135264] Sphere.0032
07:20:39,072 ERROR [Main] Geometry World BoundingBox [Center: (89.97979, -23.882013, -2.47507E-18)  xExtent: 0.5446219  yExtent: 0.35233256  zExtent: 0.53402245] Sphere.0033
07:20:39,072 ERROR [Main] Geometry World BoundingBox [Center: (89.97979, -23.911121, 0.0)  xExtent: 0.5446243  yExtent: 0.41817474  zExtent: 0.59135264] Head
07:20:39,072 ERROR [Main] Geometry World BoundingBox [Center: (89.95945, -24.507792, 0.19999999)  xExtent: 0.15944853  yExtent: 0.034612153  zExtent: 0.118897066] Cube.0021
07:20:39,072 ERROR [Main] Geometry World BoundingBox [Center: (89.95945, -24.507792, 0.19999999)  xExtent: 0.15944853  yExtent: 0.034612153  zExtent: 0.118897066] LeftFoot
07:20:39,072 ERROR [Main] Geometry World BoundingBox [Center: (89.95945, -24.507792, -0.19999999)  xExtent: 0.15944853  yExtent: 0.034612153  zExtent: 0.11889708] Cube.0011
07:20:39,072 ERROR [Main] Geometry World BoundingBox [Center: (89.95945, -24.507792, -0.19999999)  xExtent: 0.15944853  yExtent: 0.034612153  zExtent: 0.11889708] RightFoot
07:20:39,072 ERROR [Main] Geometry World BoundingBox [Center: (89.97979, -24.017675, 0.0)  xExtent: 0.5446243  yExtent: 0.5247288  zExtent: 0.64846516] Scene
07:20:39,072 ERROR [Main] Geometry World BoundingBox [Center: (89.97979, -24.017675, 0.0)  xExtent: 0.5446243  yExtent: 0.5247288  zExtent: 0.64846516] Models/Redneck.blend
07:20:39,072 ERROR [Main] Geometry World BoundingBox [Center: (49.926914, -23.912628, -4.4703484E-8)  xExtent: 0.15524018  yExtent: 0.15524015  zExtent: 0.1097714] Sphere.0021
07:20:39,073 ERROR [Main] Geometry World BoundingBox [Center: (49.926914, -23.912628, -4.4703484E-8)  xExtent: 0.15524018  yExtent: 0.15524015  zExtent: 0.1097714] AimingDevice
07:20:39,073 ERROR [Main] Geometry World BoundingBox [Center: (49.08757, -24.253157, -0.56120473)  xExtent: 0.10546381  yExtent: 0.10668856  zExtent: 0.087260425] Sphere.0061
07:20:39,073 ERROR [Main] Geometry World BoundingBox [Center: (49.08757, -24.253157, -0.56120473)  xExtent: 0.10546381  yExtent: 0.10668856  zExtent: 0.087260425] LeftArm
07:20:39,073 ERROR [Main] Geometry World BoundingBox [Center: (48.748596, -24.253157, 0.56120473)  xExtent: 0.10546381  yExtent: 0.10668856  zExtent: 0.087260425] Sphere.0041
07:20:39,073 ERROR [Main] Geometry World BoundingBox [Center: (48.748596, -24.253157, 0.56120473)  xExtent: 0.10546381  yExtent: 0.10668856  zExtent: 0.087260425] RightArm
07:20:39,073 ERROR [Main] Geometry World BoundingBox [Center: (48.811718, -24.236467, 0.0)  xExtent: 0.4990983  yExtent: 0.09616068  zExtent: 0.49999982] Sphere1
07:20:39,073 ERROR [Main] Geometry World BoundingBox [Center: (48.81262, -24.23501, 0.0)  xExtent: 0.49999985  yExtent: 0.094702706  zExtent: 0.49999982] Sphere2
07:20:39,073 ERROR [Main] Geometry World BoundingBox [Center: (48.81262, -24.236467, 0.0)  xExtent: 0.5  yExtent: 0.09616089  zExtent: 0.49999982] Body
07:20:39,073 ERROR [Main] Geometry World BoundingBox [Center: (48.810604, -23.952877, 0.0)  xExtent: 0.46176147  yExtent: 0.26147476  zExtent: 0.46929386] Sphere.0031
07:20:39,073 ERROR [Main] Geometry World BoundingBox [Center: (48.806095, -23.867662, 0.0)  xExtent: 0.5178876  yExtent: 0.26231414  zExtent: 0.59135264] Sphere.0032
07:20:39,073 ERROR [Main] Geometry World BoundingBox [Center: (48.756134, -23.725767, 0.0)  xExtent: 0.46792597  yExtent: 0.2896693  zExtent: 0.51010865] Sphere.0033
07:20:39,073 ERROR [Main] Geometry World BoundingBox [Center: (48.806095, -23.825226, 0.0)  xExtent: 0.5178871  yExtent: 0.38912773  zExtent: 0.59135264] Head
07:20:39,073 ERROR [Main] Geometry World BoundingBox [Center: (49.022655, -24.380424, -0.19999999)  xExtent: 0.15944853  yExtent: 0.032203004  zExtent: 0.118897066] Cube.0021
07:20:39,073 ERROR [Main] Geometry World BoundingBox [Center: (49.022655, -24.380424, -0.19999999)  xExtent: 0.15944853  yExtent: 0.032203004  zExtent: 0.118897066] LeftFoot
07:20:39,073 ERROR [Main] Geometry World BoundingBox [Center: (48.68368, -24.380424, 0.19999999)  xExtent: 0.15944853  yExtent: 0.032203004  zExtent: 0.11889708] Cube.0011
07:20:39,073 ERROR [Main] Geometry World BoundingBox [Center: (48.68368, -24.380424, 0.19999999)  xExtent: 0.15944853  yExtent: 0.032203004  zExtent: 0.11889708] RightFoot
07:20:39,073 ERROR [Main] Geometry World BoundingBox [Center: (49.18518, -23.924362, 0.0)  xExtent: 0.89697266  yExtent: 0.48826408  zExtent: 0.64846516] Scene
07:20:39,074 ERROR [Main] Geometry World BoundingBox [Center: (49.18518, -23.924362, 0.0)  xExtent: 0.89697266  yExtent: 0.48826408  zExtent: 0.64846516] Models/Agent.blend
07:20:39,074 ERROR [Main] Geometry World BoundingBox [Center: (0.0, 0.0, 0.0)  xExtent: 0.0  yExtent: 0.0  zExtent: 0.0] null
07:20:39,074 ERROR [Main] Geometry World BoundingBox [Center: (0.0, 0.0, 0.0)  xExtent: 0.0  yExtent: 0.0  zExtent: 0.0] null
07:20:39,074 ERROR [Main] Geometry World BoundingBox [Center: (49.5, -13.73765, -0.49999952)  xExtent: 50.0  yExtent: 13.73765  zExtent: 1.5000005] Root Node
07:20:39,074 ERROR [Main] Camera location: (48.81262, -24.015074, 260.0), orientation: (0.0, 1.0, -0.0, -4.371139E-8)

I don’t see something suspicious (it’s just a snippet). And as I can change random code like removing or slightly rewriting which has influence if the exception is happening or not is a bit a sign that something bleeds. This kind of bleeding I know from C/C++ and memory violations…

Any way atm I don’t see a way out except swallow the exception, which is clearly not very nice I know that.

The null elements are possibly elements that you have created with new Node()

1 Like

Ye think as well. I check the code and give them names.

Next step would be to go through each of the GeometryLists and see which one fails to sort by trying to sort it again (when you receive the exception).

There’s no “leaking” in the C++ memory leak sense. Something is wrong and you can find it… or you are using multiple threads (or networking) and haven’t realize that you are clobbering something.

1 Like

It’s one thread no networking. I’m not totally sure if one of my used libs like behavior tree from libgdx-ai or dyn4j does some threading behind the scenes.
Ok I try what you say.

You could try jVisualVM to see the whole picture about your app.

1 Like

At the moment I can not reproduce it on my stationary PC. @pspeed I tried to figure out what you meant by print the geometry list and sort it but somehow I’m lost with that. Just in case it happens again. The traversal I use probably prints all geometries at least when I look at the names they match with the blender names

The assumption is that you only use the default viewports and this is not in the GUI viewport (though this could be extended to that).

https://javadoc.jmonkeyengine.org/v3.3.2-stable/com/jme3/app/Application.html#getViewPort--
https://javadoc.jmonkeyengine.org/v3.3.2-stable/com/jme3/renderer/ViewPort.html#getQueue--

But from there I guess JME does not provide direct access to the GeometryList and so it would take some reflection trickery to get it.

Anyway, in the process of tracking that down I discovered that the stack trace is already showing us which queue (presuming the source code matches)… it’s the opaque bucket.

I don’t know how many items are in view in your opaque bucket at the time of the crash but it seems like 10 or 11.

The idea was to try to narrow it down to which 10 or 11 to figure out where the sorting goes wrong by manually sorting them and/or doing some item->item comparisons.

It might be interesting to at least log the comparator that is used for the opaque bucket:
https://javadoc.jmonkeyengine.org/v3.3.2-stable/com/jme3/renderer/queue/RenderQueue.html#getGeometryComparator-com.jme3.renderer.queue.RenderQueue.Bucket-

1 Like

Ye that is right just plain simple IMO


    @Override
    protected void initialize(Application app) {
        modelRoot = new Node();
        guiRoot = new Node();
        main = (Main) app;
        feather = main.getStateManager().getState(FeatherState.class).feather();

        this.fpp = new FilterPostProcessor(((Main) getApplication()).getAssetManager());

        FXAAFilter fxaa = new FXAAFilter();
        fpp.addFilter(fxaa);

        ToonFilter toon = new ToonFilter();
        fpp.addFilter(toon);

        BarrelDistortionFilter barrelDistortion = new BarrelDistortionFilter();
        fpp.addFilter(barrelDistortion);

        main.getViewPort().addProcessor(fpp);

        ed = main.getStateManager().getState(EntityDataState.class).getEntityData();
    }

Can those filter have this effect I observe? Specially the barrel distortion filter? Or my simple toon filter?

1 Like

Just in case, I can not reproduce the issue after I did a total clean and build everything again. So might be that something was off and caused the problem.

Anyway thanks you all for your help :slight_smile:

1 Like