Nullpointer during rendering and/or collision detection

Revision as of 09:05, 26 April 2013 by Admin (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The problem

From time to time, your application exits with a null pointer exception in either the rendering thread or while calling one of the collision detection methods.

Possible reason

jPCT (as well as jPCT-AE) isn't thread safe. That means that at runtime, no other thread is allowed to work on jPCT related object than the rendering thread itself. If you are familiar with the way in which Swing works: It's very similar to that.

If you encounter this problem, the most likely reason is that you are doing work in multiple threads which should be done in the render thread only. This often happens if one works on jPCT related instances in some event listener method.


Don't do this. Let the event listener method set a flag, evaluate this in the render thread and do the work there.