psmoveservice / psmove-ue4

Plugin for using PSMove as input into Unreal Engine 4. Currently obsolete. Please use PSMoveService.
GNU General Public License v2.0
59 stars 28 forks source link

Win32 CL-EYE build, crash on psmove_enable_orientation #19

Closed Ixstala closed 8 years ago

Ixstala commented 8 years ago

I've been experiencing crashes on first startup when trying to call psmove_enable_orientation. The crash occurs during psmove_orientation_reset_quaternion. This happens with the test_opengl example and in my own code. I've built your fork of psmoveapi in msvc 2013 with win32 targets and the CAMERA_CONTROL_USE_CL_DRIVER flag defined. The 64 bit build with lib-usb does not exhibit this problem.

If I keep re-running test_opengl occasionally it will work. Any ideas?

Thanks!

Here's my call stack at the exception:

psmoveapi.dll!Eigen::internal::pload<__m128>(const float * from) Line 275 C++ psmoveapi.dll!Eigen::internal::ploadt<__m128,16>(const float * from) Line 458 C++ psmoveapi.dll!Eigen::PlainObjectBaseEigen::Matrix<float,4,1,0,4,1 >::packet<16>(int index) Line 207 C++ psmoveapi.dll!Eigen::internal::quat_conj<1,Eigen::Quaternion<float,0>,float,16>::run(const Eigen::QuaternionBaseEigen::Quaternion<float,0 > & q) Line 46 C++ psmoveapi.dll!Eigen::QuaternionBaseEigen::Quaternion<float,0 >::conjugate() Line 675 C++ psmoveapi.dll!psmove_orientation_reset_quaternion(_PSMoveOrientation * orientation_state) Line 456 C++ psmoveapi.dll!psmove_reset_orientation(_PSMove * move) Line 1946 C psmoveapi.dll!psmove_enable_orientation(_PSMove * move, PSMove_Bool enabled) Line 1916 C test_opengl.exe!Tracker::Tracker() Line 135 C++ test_opengl.exe!SDL_main(int argc, char * * argv) Line 427 C++ test_opengl.exe!main_utf8(int argc, char * * argv) Line 126 C test_opengl.exe!main(int argc, char * * argv) Line 134 C

brendanwalker commented 8 years ago

Ah this is an issue because I put Eigen::Quaternionf on structures that aren't marked as 128 bit aligned. I must have been lucky and those structures were getting aligned in 64-bit builds (because of the 8-byte pointers?). Now that you are building in 32-bit you are hitting this issue. If you are building locally, you can build psmoveapi with the EIGEN_DONT_VECTORIZE compiler option. I can submit a proper pull request to tonight to fix the issue. The easiest thing is probably to just not be putting Eigen::Quaternionf's on structs allocated on the heap and only use those on the stack.

Ixstala commented 8 years ago

I'll try that in the morning, thanks!

Any other compiler options I should know about?

brendanwalker commented 8 years ago

I have a pending pull request with this fix waiting to go into psmoveapi (which will then feed into psmove-ue4): https://github.com/cboulay/psmoveapi/pull/12/files

The key fix is in psmove_orientation.cpp. It'll probably take a few days for this to make it up into psmove-ue4, so if you want this fix now and you have psmoveapi built locally, you can just copy over this one file in the mean time.

Ixstala commented 8 years ago

Seems to be working! I'll continue testing a bit, but I'm going to mark this as closed now.

Thanks!