Hello Guest

VRTrackedCamera NullPointerException

  • 6 Replies
  • 468 Views
VRTrackedCamera NullPointerException
« on: September 05, 2018, 08:39:02 »
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

Code: [Select]
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:
Code: [Select]
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.


« Last Edit: September 05, 2018, 10:03:16 by neph »

*

Offline spasi

  • *****
  • 2044
    • WebHotelier
Re: VRTrackedCamera NullPointerException
« Reply #1 on: September 06, 2018, 08:17:19 »
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:

Code: [Select]
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));
        }
    }
}

Re: VRTrackedCamera NullPointerException
« Reply #2 on: September 10, 2018, 05:26:57 »
Thanks, and sorry for the late reply.

The only error I get with that code is:

Code: [Select]
Failed to retrieve IVRTrackedCamera_003. Error: 105
Is it this error it's refering to?

Code: [Select]
EVRInitError_VRInitError_Init_InterfaceNotFound = 105
« Last Edit: September 10, 2018, 05:41:06 by neph »

*

Offline spasi

  • *****
  • 2044
    • WebHotelier
Re: VRTrackedCamera NullPointerException
« Reply #3 on: September 10, 2018, 05:51:32 »
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.

Re: VRTrackedCamera NullPointerException
« Reply #4 on: September 10, 2018, 06:13:10 »
It seems that opting out of the beta and reinstalling SteamVR solved the issue.

Thanks for the help.


Re: VRTrackedCamera NullPointerException
« Reply #5 on: September 10, 2018, 07:59:47 »
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
Code: [Select]
VRTrackedCamera_GetVideoStreamFrameBuffer to check if there's a new frame available.

Ref:

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

However, this yiels a NPE:

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

More specifically:

Code: [Select]
memAddress(pFrameBuffer)
Workaround:
Call
Code: [Select]
VRTrackedCamera.nVRTrackedCamera_GetVideoStreamFrameBuffer directly

Should I report this on github?


*

Offline spasi

  • *****
  • 2044
    • WebHotelier
Re: VRTrackedCamera NullPointerException
« Reply #6 on: September 10, 2018, 08:20:05 »
Thanks, will be fixed in the next 3.2.1 snapshot. In the meantime, a workaround is to use nVRTrackedCamera_GetVideoStreamFrameBuffer instead.