Using native bullet occasionally crashes jMonkey

Hey there.

So I’ve moved to native bullet but it sometimes throws an error window like in the picture and then a “Java™ has stopped working” window appears but it does not throw a stack trace.

Can anyone explain why this keeps happening?

Could this be because of collision shape scaling because the app crashes when I use a method that involves collision scaling.

Do you add the RigidBodyControls in code or do you add them with the SDK (SceneComposer)?

I once had such a crash too. As far as I know the SDK uses its own libraries, so it could be that those libraries somehow interfere with the ones you use in your application. But please tell me, if I am wrong here!

This method is when the error occurs. I fiddle with collsion shapes for character controls and the app is likely to crash but instead of throwing an exception, an error message like that in the screenshot appears followed by “Java has stopped working”.

Note this hasn’t happened when I was using jBullet. And also, I’m using Eclipse, not JME SDK.

 public void prone() {
	if (!prone) {
		prone = true;
		proning = true;
		if (!crouched) {
		crouched = false;
		character = c;
		setAnim(headChannel, "lookingStraightProning", LoopMode.DontLoop, 1, 0);
		setAnim(handsChannel, "holding" + weaponsList[weapons[weaponSelection].getWeaponId()] + "Proning",
				LoopMode.DontLoop, 1, 0);
		setAnim(legsChannel, "proning", LoopMode.DontLoop, 1, 0);
	} else {
		proning = true;
		setAnim(headChannel, "lookingStraightProningBackwards", LoopMode.DontLoop, 1, 0);
		setAnim(handsChannel, "holding" + weaponsList[weapons[weaponSelection].getWeaponId()] + "ProningBackwards",
				LoopMode.DontLoop, 1, 0);
		torsoChannel.setAnim("lookingVerticallyProningBackwards", 0);
		setAnim(legsChannel, "proningBackwards", LoopMode.DontLoop, 1, 0);
		CharacterControl c = new CharacterControl(new CapsuleCollisionShape(2, 4.6f, 1), 1f);
		c.getCollisionShape().setScale(new Vector3f(1, .8f, 1));
		character = c;
		angle = 90;

But it’s more likely to occur when I add rigid bodies.

If I were you I would step by step comment out your code and see where exactly (on which line) the error occurs.

How have you caused such a crash?

Well, since you don’t use the SDK, we can’t really compare our situations … My game crashed when I tried to load a model which has an RigidBodyControl added. You seem to be in another situation though…

There was a thread here about this issue less than one week ago and I think @Empire_Phoenix wanted to investigate that.
Try a scale of (1,1,1) or at least a uniform scale (that means x=y=z) and see if the errors still occur.

Ok, now that I’m using the (1,1,1) scale the error does not seem to occur.

But why would this never come up when using jBullet?
Please check if the testcase does crash for you, and report with as much detail as possible jme version, systeminformation ect.

This testcase crashes (throws “Java has stopped working” error window) every time I run it (with native bullet).

import java.util.logging.Level;
import java.util.logging.Logger;
import com.jme3.asset.plugins.FileLocator;
import com.jme3.bullet.collision.shapes.CollisionShape;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.bullet.util.CollisionShapeFactory;
import com.jme3.export.binary.BinaryExporter;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;

public class BulletSigsevOnScaleTestCase extends SimpleApplication {

public static void main(String[] args) {
	BulletSigsevOnScaleTestCase app = new BulletSigsevOnScaleTestCase();

public void simpleInitApp() {
	Box box = new Box(1, 1, 1);
	Geometry geom = new Geometry("box", box);

	Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
	mat.setColor("Color", ColorRGBA.Blue);


	File saveFile = new File(System.getProperty("user.home") + File.separatorChar + "testRigidBody.j3o");

	CollisionShape collisionShape = CollisionShapeFactory.createMeshShape(geom);
	RigidBodyControl rigidBodyControl = new RigidBodyControl(collisionShape, 0f);


	try {
		BinaryExporter.getInstance().save(rigidBodyControl, saveFile);
	} catch (IOException ex) {
		Logger.getLogger(BulletSigsevOnScaleTestCase.class.getName()).log(Level.SEVERE, null, ex);

	assetManager.registerLocator(System.getProperty("user.home"), FileLocator.class);

Console output:

Vas 05, 2017 2:37:33 PM java.util.prefs.WindowsPreferences <init>
WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5.
Vas 05, 2017 2:37:35 PM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.1-beta1
 * Branch: HEAD
 * Git Hash: 310f4db
 * Build Date: 2016-04-25
Vas 05, 2017 2:37:35 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 2.9.3 context running on thread jME3 Main
 * Graphics Adapter: igdumdim64
 * Driver Version:
 * Scaling Factor: 1
Vas 05, 2017 2:37:35 PM com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFO: OpenGL Renderer Information
 * Vendor: NVIDIA Corporation
 * Renderer: GeForce GTX 1060 6GB/PCIe/SSE2
 * OpenGL Version: 4.5.0 NVIDIA 372.90
 * GLSL Version: 4.50 NVIDIA
 * Profile: Compatibility
Vas 05, 2017 2:37:35 PM initOpenAL
INFO: Audio Renderer Information
 * Device: OpenAL Soft
 * Vendor: OpenAL Community
 * Renderer: OpenAL Soft
 * Version: 1.1 ALSOFT 1.15.1
 * Supported channels: 64
 * AL extensions: AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_source_latency
Vas 05, 2017 2:37:35 PM initOpenAL
WARNING: Pausing audio device not supported.
Vas 05, 2017 2:37:35 PM initOpenAL
INFO: Audio effect extension version: 1.0
Vas 05, 2017 2:37:35 PM initOpenAL
INFO: Audio max auxiliary sends: 4
Bullet-Native: Initializing java classes

While I kinda fear it will not change much, what happens if you run the current beta3? or master?

With jMonkey 3.0 the test case does not crash if that helps.

jBullet and native Bullet are two very, very different things that are probably internally implemented in significantly different ways.There are a whole host of reasons why this could happen with native bullet but not jBullet. In short, somewhere in the depths of Bullet’s C++ code or in the jME interfacing code there’s a bug that causes native Bullet to crash when some situations involving object scales occur.

If I’m not mistaken, I’ve had the same error pop up when running an old pc game I had downloaded before. :smile: