VRTrackedCamera NullPointerException

Started by neph, September 05, 2018, 08:39:02

Previous topic - Next topic

neph

Good morning. Sorry to make my first post a bug report(?)

Edit: I downgraded by SteamVR beta to regular release. Then my testcase passed, but any call to VRSystem gets a NPE instead. So I'm guessing it has something to do with the underlying API..

I'm working on migrating jMonkeyEngine's OpenVR implementation to lwjgl's backend, using lwjgl 3.2.0.

Most of it is working, but I can't get the camera to work. Any call I make to VRTrackedCamera results in a NullPointerException

Exception in thread "main" java.lang.NullPointerException
	at org.lwjgl.openvr.VRTrackedCamera.nVRTrackedCamera_GetCameraErrorNameFromEnum(VRTrackedCamera.java:30)
	at org.lwjgl.openvr.VRTrackedCamera.VRTrackedCamera_GetCameraErrorNameFromEnum(VRTrackedCamera.java:45)
	at test.TestError.main(TestError.java:28)


Minimal test case:
public class TestError {
    
    public static void main(String... args){
        IntBuffer peError = BufferUtils.createIntBuffer(1);
        int token = VR.VR_InitInternal(peError, VR.EVRApplicationType_VRApplication_Scene);
        if (peError.get(0) == 0) {
            OpenVR.create(token);
//            long result = VR.VR_GetGenericInterface(VR.IVRTrackedCamera_Version, peError);
            int error = 0;
            String s = VRTrackedCamera.VRTrackedCamera_GetCameraErrorNameFromEnum(error);
            System.out.println("error " + s);
        }
    }
}


Any help is appreciated, thanks.



spasi

I can reproduce the original NPE, but only if I pass EVRApplicationType_VRApplication_Utility to VR_InitInternal. Try this code to see what errors you're getting:

private static void check() {
    check(IVRSystem_Version);
    check(IVRApplications_Version);
    check(IVRChaperone_Version);
    check(IVRChaperoneSetup_Version);
    check(IVRCompositor_Version);
    check(IVRDriverManager_Version);
    check(IVRExtendedDisplay_Version);
    check(IVRNotifications_Version);
    check(IVROverlay_Version);
    check(IVRRenderModels_Version);
    check(IVRResources_Version);
    check(IVRScreenshots_Version);
    check(IVRSettings_Version);
    check(IVRTrackedCamera_Version);
    check(IVRInput_Version);
    check(IVRIOBuffer_Version);
    check(IVRSpatialAnchors_Version);
}

private static void check(String interfaceNameVersion) {
    try (MemoryStack stack = stackPush()) {
        IntBuffer peError = stack.mallocInt(1);

        long ivr = VR_GetGenericInterface("FnTable:" + interfaceNameVersion, peError);
        if (ivr == NULL) {
            System.out.println("Failed to retrieve " + interfaceNameVersion + ". Error: " + peError.get(0));
        }
    }
}

neph

Thanks, and sorry for the late reply.

The only error I get with that code is:

Failed to retrieve IVRTrackedCamera_003. Error: 105


Is it this error it's refering to?

EVRInitError_VRInitError_Init_InterfaceNotFound = 105

spasi

Yes, that's the error. Sounds like SteamVR is broken on your system somehow, try re-installing it. The check code above is basically what LWJGL uses to retrieve the OpenVR function pointers, the bindings can't work if it fails.

neph

It seems that opting out of the beta and reinstalling SteamVR solved the issue.

Thanks for the help.


neph

Hello again.

Another issue (but the title is still correct), and I think it's a real one, this time.

I'm supposed to be able to send a null frameBuffer to
VRTrackedCamera_GetVideoStreamFrameBuffer
to check if there's a new frame available.

Ref:

QuoteA caller can provide null for the framebuffer or frameheader if not desired.

However, this yiels a NPE:

java.lang.NullPointerException
	at org.lwjgl.system.MemoryUtil.memAddress(MemoryUtil.java:646)
	at org.lwjgl.openvr.VRTrackedCamera.VRTrackedCamera_GetVideoStreamFrameBuffer(VRTrackedCamera.java:190)


More specifically:

memAddress(pFrameBuffer)


Workaround:
Call
VRTrackedCamera.nVRTrackedCamera_GetVideoStreamFrameBuffer
directly

Should I report this on github?


spasi

Thanks, will be fixed in the next 3.2.1 snapshot. In the meantime, a workaround is to use nVRTrackedCamera_GetVideoStreamFrameBuffer instead.