Closed
Description
I'm testing current "master" branch with FBX assets downloaded from CGtrader, Mixamo, and Sketchfab.
Attempting to load any file with version > 7400 results in an OutOfMemoryError
.
For example:
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.OutOfMemoryError: Java heap space
at java.base/java.util.ArrayList.<init>(ArrayList.java:156)
at com.jme3.scene.plugins.fbx.file.FbxElement.<init>(FbxElement.java:61)
at com.jme3.scene.plugins.fbx.file.FbxReader.readFBXElement(FbxReader.java:92)
at com.jme3.scene.plugins.fbx.file.FbxReader.readFBXElement(FbxReader.java:102)
at com.jme3.scene.plugins.fbx.file.FbxReader.readFBX(FbxReader.java:77)
at com.jme3.scene.plugins.fbx.FbxLoader.loadData(FbxLoader.java:149)
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:83)
at jme3test.helloworld.HelloJME3.simpleInitApp(HelloJME3.java:57)
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 proximate cause of the crash is that the importer reads a huge number of properties (propCount
) for an element --- as in more than 10^9 properties!
Apparently there were fundamental changes to how FBX elements are written between file versions 7400 and 7500.
In particular:
- the "endOffset", "propCount", and "propsLength" fields were extended from 4 bytes to 8 bytes each and
- the length of the block sentinel was reduced from 13 bytes to 9 bytes.
FbxReader
was probably designed for file versions in the range of 7100 to 7400, so it's reading garbage for propCount
.
There are countless other issues with the FBX importer. This one, at least, looks like a simple fix.