Skip to content

NPE in FbxObject.unsupportedConnectObjectProperty() #1937

Closed
@stephengold

Description

@stephengold

I'm testing current "master" branch with FBX assets downloaded from CGtrader, Mixamo, and Sketchfab.
Attempting to import a certain FBX file causes the following crash:

Jan 29, 2023 10:11:35 AM com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.NullPointerException: Cannot invoke "com.jme3.scene.plugins.fbx.obj.FbxObject.getFullClassName()" because "object" is null
	at com.jme3.scene.plugins.fbx.obj.FbxObject.unsupportedConnectObjectProperty(FbxObject.java:134)
	at com.jme3.scene.plugins.fbx.anim.FbxAnimCurveNode.connectObjectProperty(FbxAnimCurveNode.java:129)
	at com.jme3.scene.plugins.fbx.FbxLoader.connectObjects(FbxLoader.java:261)
	at com.jme3.scene.plugins.fbx.FbxLoader.loadData(FbxLoader.java:163)
	at com.jme3.scene.plugins.fbx.FbxLoader.load(FbxLoader.java:110)
	at com.jme3.asset.DesktopAssetManager.loadLocatedAsset(DesktopAssetManager.java:272)
	at com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:388)
	at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:439)
	at com.jme3.asset.DesktopAssetManager.loadModel(DesktopAssetManager.java:444)
	at jme3test.helloworld.HelloJME3.loadModel(HelloJME3.java:88)
	at jme3test.helloworld.HelloJME3.simpleInitApp(HelloJME3.java:80)
	at com.jme3.app.SimpleApplication.initialize(SimpleApplication.java:240)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.initInThread(LwjglAbstractDisplay.java:139)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:221)
	at java.base/java.lang.Thread.run(Thread.java:833)

The crash occurs because in FbxLoader.connectObjects(), the child object (with ID 67443872) doesn't exist in objectMap:

} else if (type.equals("OP")) {
childId = FbxId.create(el.properties.get(1));
parentId = FbxId.create(el.properties.get(2));
String propName = (String) el.properties.get(3);
FbxObject child = objectMap.get(childId);
FbxObject parent = objectMap.get(parentId);
parent.connectObjectProperty(child, propName);
} else {
logger.log(Level.WARNING, "Unknown connection type: {0}. Ignoring.", type);
}

At the very least, the FBX loader could fail more gracefully, providing clues as to where the problem lies. Probably the best solution would be to warn, skip, and continue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectSomething that is supposed to work, but doesn't. Less severe than a "bug"

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions