Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ArrayIndexOutOfBoundsException when software skinning an imported glTF #2239

Open
stephengold opened this issue Mar 29, 2024 · 1 comment
Open
Labels
defect Something that is supposed to work, but doesn't. Less severe than a "bug"

Comments

@stephengold
Copy link
Member

stephengold commented Mar 29, 2024

In current "master" branch, loading a model from https://github.com/capdevon/sharefile/blob/main/RPM_RandomAvatar.glb :

Mar 29, 2024 12:39:27 PM com.jme3.system.JmeDesktopSystem initialize
INFO: Running on jMonkeyEngine 3.8.0-SNAPSHOT
 * Branch: master
 * Git Hash: 9452078
 * Build Date: 2024-03-29
Mar 29, 2024 12:39:27 PM com.jme3.system.lwjgl.LwjglContext printContextInitInfo
INFO: LWJGL 2.9.5 context running on thread jME3 Main
 * Graphics Adapter: null
 * Driver Version: null
 * Scaling Factor: 1
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.jme3.util.ReflectionAllocator (file:/home/sgold/NetBeansProjects/jmonkeyengine/jme3-core/build/libs/jme3-core-3.8.0-SNAPSHOT.jar) to method sun.nio.ch.DirectBuffer.cleaner()
WARNING: Please consider reporting this to the maintainers of com.jme3.util.ReflectionAllocator
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Mar 29, 2024 12:39:27 PM com.jme3.renderer.opengl.GLRenderer loadCapabilitiesCommon
INFO: OpenGL Renderer Information
 * Vendor: NVIDIA Corporation
 * Renderer: GeForce GT 545/PCIe/SSE2
 * OpenGL Version: 3.2.0 NVIDIA 390.157
 * GLSL Version: 1.50 NVIDIA via Cg compiler
 * Profile: Core
Mar 29, 2024 12:39:28 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio Renderer Information
 * Device: OpenAL Soft
 * Vendor: OpenAL Community
 * Renderer: OpenAL Soft
 * Version: 1.1 ALSOFT 1.15.1
 * Supported channels: 64
 * ALC extensions: ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX ALC_EXT_thread_local_context ALC_SOFT_loopback
 * 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
Mar 29, 2024 12:39:28 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
WARNING: Pausing audio device not supported.
Mar 29, 2024 12:39:28 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio effect extension version: 1.0
Mar 29, 2024 12:39:28 PM com.jme3.audio.openal.ALAudioRenderer initOpenAL
INFO: Audio max auxiliary sends: 4
Mar 29, 2024 12:39:30 PM com.jme3.app.LegacyApplication handleError
SEVERE: Uncaught exception thrown in Thread[jME3 Main,5,main]
java.lang.ArrayIndexOutOfBoundsException: Index 67 out of bounds for length 67
	at com.jme3.anim.SkinningControl.applySkinningTangents(SkinningControl.java:659)
	at com.jme3.anim.SkinningControl.softwareSkinUpdate(SkinningControl.java:453)
	at com.jme3.anim.SkinningControl.controlRenderSoftware(SkinningControl.java:264)
	at com.jme3.anim.SkinningControl.controlRender(SkinningControl.java:304)
	at com.jme3.scene.control.AbstractControl.render(AbstractControl.java:126)
	at com.jme3.scene.Spatial.runControlRender(Spatial.java:763)
	at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:809)
	at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:819)
	at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:819)
	at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:793)
	at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:1210)
	at com.jme3.renderer.RenderManager.render(RenderManager.java:1292)
	at com.jme3.app.SimpleApplication.update(SimpleApplication.java:283)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:163)
	at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:225)
	at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:245)
	at java.base/java.lang.Thread.run(Thread.java:829)

Here's the essence of the test app:

    public void simpleInitApp() {
        Spatial model = assetManager.loadModel("RPM_RandomAvatar.glb");
        rootNode.attachChild(model);

        Spatial child = ((Node) model).getChild(0);
        SkinningControl skinningControl
                = child.getControl(SkinningControl.class);
        skinningControl.setHardwareSkinningPreferred(false);
    }

A runtime check could easily be added to SkinningControl, like so:

                    int index = ib.get(idxWeights++);
                    if (index < 0 || index >= offsetMatrices.length) {
                        continue;
                    }
                    Matrix4f mat = offsetMatrices[index];

However, it would be even better for jme3-plugins to detect the out-of-range bone index while importing the model.

@stephengold
Copy link
Member Author

This issue existed in v3.6.1, so it's not a regression for v3.7.x .

@stephengold stephengold added the defect Something that is supposed to work, but doesn't. Less severe than a "bug" label Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Something that is supposed to work, but doesn't. Less severe than a "bug"
Projects
None yet
Development

No branches or pull requests

1 participant