TerrainLODControl NullPointerException

Hi

When running game some times very rarely (mostly when doing sys.out.print to console continuously in a loop) i get

zone update underflow FPS:59
22:04:04,089 ERROR [TerrainLodControl] null
java.util.concurrent.ExecutionException: java.lang.NullPointerException
	at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_112]
	at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_112]
	at com.jme3.terrain.geomipmap.TerrainLodControl.updateQuadLODs(TerrainLodControl.java:253) [jme3-terrain-3.2.0-SNAPSHOT.jar:3.2-1]
	at com.jme3.terrain.geomipmap.TerrainLodControl.updateLOD(TerrainLodControl.java:191) [jme3-terrain-3.2.0-SNAPSHOT.jar:3.2-1]
	at com.jme3.terrain.geomipmap.TerrainLodControl.controlUpdate(TerrainLodControl.java:170) [jme3-terrain-3.2.0-SNAPSHOT.jar:3.2-1]
	at com.jme3.scene.control.AbstractControl.update(AbstractControl.java:128) [jme3-core-3.2.0-SNAPSHOT.jar:3.2-1]
	at com.jme3.scene.Spatial.runControlUpdate(Spatial.java:736) [jme3-core-3.2.0-SNAPSHOT.jar:3.2-1]
	at com.jme3.scene.Spatial.updateLogicalState(Spatial.java:879) [jme3-core-3.2.0-SNAPSHOT.jar:3.2-1]
	at com.jme3.scene.Node.updateLogicalState(Node.java:230) [jme3-core-3.2.0-SNAPSHOT.jar:3.2-1]
	at com.jme3.scene.Node.updateLogicalState(Node.java:241) [jme3-core-3.2.0-SNAPSHOT.jar:3.2-1]
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:242) [jme3-core-3.2.0-SNAPSHOT.jar:3.2-1]
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151) [jme3-lwjgl-3.2.0-SNAPSHOT.jar:3.2-1]
	at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:197) [jme3-lwjgl-3.2.0-SNAPSHOT.jar:3.2-1]
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:232) [jme3-lwjgl-3.2.0-SNAPSHOT.jar:3.2-1]
	at java.lang.Thread.run(Thread.java:745) [?:1.8.0_112]
Caused by: java.lang.NullPointerException
	at com.jme3.math.Vector3f.distanceSquared(Vector3f.java:450) ~[jme3-core-3.2.0-SNAPSHOT.jar:3.2-1]
	at com.jme3.math.Vector3f.distance(Vector3f.java:464) ~[jme3-core-3.2.0-SNAPSHOT.jar:3.2-1]
	at com.jme3.terrain.geomipmap.lodcalc.DistanceLodCalculator.calculateLod(DistanceLodCalculator.java:68) ~[jme3-terrain-3.2.0-SNAPSHOT.jar:3.2-1]
	at com.jme3.terrain.geomipmap.TerrainQuad.calculateLod(TerrainQuad.java:365) ~[jme3-terrain-3.2.0-SNAPSHOT.jar:3.2-1]
	at com.jme3.terrain.geomipmap.TerrainQuad.calculateLod(TerrainQuad.java:361) ~[jme3-terrain-3.2.0-SNAPSHOT.jar:3.2-1]
	at com.jme3.terrain.geomipmap.TerrainQuad.calculateLod(TerrainQuad.java:361) ~[jme3-terrain-3.2.0-SNAPSHOT.jar:3.2-1]
	at com.jme3.terrain.geomipmap.TerrainLodControl$UpdateLOD.call(TerrainLodControl.java:416) ~[jme3-terrain-3.2.0-SNAPSHOT.jar:3.2-1]
	at com.jme3.terrain.geomipmap.TerrainLodControl$UpdateLOD.call(TerrainLodControl.java:396) ~[jme3-terrain-3.2.0-SNAPSHOT.jar:3.2-1]
	at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_112]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[?:1.8.0_112]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[?:1.8.0_112]
	... 1 more
zone update underflow FPS:59

Just in case, may using FastMath in other thread have anything to do with this error ? I am using it in some of my systems concurrently.

Just wanted to inform about this.

It shouldn’t… since the error is that Vector3f.distance() was passed a null vector.

…which in turn means that this method was passed a list with a null entry:

…not sure why that can happen but now it falls outside of my area of concern/expertise.

Hi Ali_Rs,

Are you using integrated graphics?

Nope, i am using my PC with Nvidia graphics card on Linux.

Ok, thanks. Thought maybe that was my problem since I get this exact same error and have been messing around with it for over a week now.

I thought possible causes were rounding errors caused by JME3 using floats for everything or maybe Vertex Buffer Object problems related to my use of onboard graphics.

I can drop a camera from above a heightmap generated terrain and let it float to the ground and it will cause this to happen nearly every time immediately but when stepping through with debugger it will never happen.

On a side note, that link in one of your posts on generating heightmaps in blender using Displacement mode is awesome.

My random guess is that it’s a threading issue. I sort of remember others posting some similar issues and how to work around it by using a shared thread executor or something.

My thought is that continuously updating camera position in our AppState is interrupting with TerrainLODControl thread.

Thanks :slight_smile:

My recollection is that each terrain quad or whatever gets its own threads or something… unless you specify your own thread executor that is shared across all of them.

You could probably search for terrain and executor to see if those threads have anything to do with this.