OculusRiftInAction / pyovr-examples

Examples for Oculus Rift in Action in Python
Apache License 2.0
11 stars 2 forks source link

Segmentation Fault in `ovr.ovrHmd_AttachToWindow` #9

Open cversek opened 8 years ago

cversek commented 8 years ago

I'm trying to use the RiftDemo.py with example with the ovrsdk Python bindings and version 0.5 of the OVR SDK on linux (Ubuntu 15.10). I get an error message:

Fatal Python error: (pygame parachute) Segmentation Fault
Aborted (core dumped)

which I traced to the API call ovr.ovrHmd_AttachToWindow(self.hmd.hmd, window, 0, 0). Here is a sample of the arguments being fed to that function:

self.hmd.hmd: <oculusvr.LP_struct_ovrHmdDesc_ object at 0x7f0a3d8299e0>
window: c_void_p(71303185)

I also tried substituting the file ovr_sdk_linux_0.5.0.1/LibOVR/Lib/Linux/x86_64/Release/libOVRRT64_0.so.5.0.1 for the library file at python-ovrsdk/oculusvr/linux-x86-64/libOculusVR.so but that created a segmentation fault at ovr.Hmd.initialize().

jherico commented 8 years ago

ovrHmd_AttachToWindow is only required for functionality on Win32 platforms. If you remove that line, it should probably work.

cversek commented 8 years ago

Thanks. Removing that call seems to get me past that part.

Now the demo is failing at the line

self.hmd.configure_rendering(rc, self.fovPorts)

with this output:

Error: [Context] Unable to obtain x11 visual from context
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  155 (GLX)
  Minor opcode of failed request:  3 (X_GLXCreateContext)
  Value in failed request:  0x0
  Serial number of failed request:  35
  Current serial number in output stream:  35

Please let me know if you need any more info.

BTW, I am running the app with this command line:

LD_PRELOAD="/usr/lib/x86_64-linux-gnu/libGL.so" python  RiftDemo.py

or else running without the preload that causes this error:

ImportError: /usr/lib/python2.7/dist-packages/oculusvr/linux-x86-64/libOculusVR.so: undefined symbol: glXMakeCurrent
jherico commented 8 years ago

The rc value passed to configure_rendering is a wrapper for the ovrRenderAPIConfig defined here

On some platforms it was necessary to set additional platform specific values in the structure by casting it to a ovrGLConfigData and populating the per-platform members. The documentation there says doing so is optional and that if you don't set it it should gather the information automatically from the current context as provided by glXGetCurrentDisplay. However, it looks like that's not working for you. You might be able to make it work by injecting the appropriate XDisplay value into the ovrRenderAPIConfig.PlatformData member, but unfortunately I don't have enough knowledge to tell you confidently how to do that. Sorry.

cversek commented 8 years ago

I was poking around in ovrGLConfigData in ipython and found that the only field that is defined is the Header:

In [4]: ovr.ovrGLConfigData._fields_
Out[4]: [('Header', oculusvr.struct_ovrRenderAPIConfigHeader_)]

I am guessing that the macro OVR_OS_LINUX in this line was not defined when the library was built.

So I tried to rebuild the SDK from your commit 838b0d3bf042ebd76019aed0a7efb08dc76768c2, but ran into this problem:

OculusSDK$ make release
Makefile:1: LibOVR/Projects/Linux/LibOVRConfig.mk: No such file or directory
make: *** No rule to make target 'LibOVR/Projects/Linux/LibOVRConfig.mk'.  Stop.

I figure that the cmake stuff is there for a reason, but I really don't know how to proceed. Thanks.

jherico commented 8 years ago

The platform data definition is in the header. I didn't attempt to do per-platform versions of the ovrGLConfigData. You would need to directly modify the ovrRenderAPIConfigHeader.PlatformData values to properly encode the Display*.