Forum Discussion
SteveTack
11 years agoHonored Guest
Unity crash when activating OVRManager
I’m making a game where you can switch between VR and 2D mode at will by hitting a key or setting “VR mode” on or off in the options. In the older SDK 0.2.x versions with DK1, it worked fine.
But I’ve run into a problem with all of the SDK 0.4.x versions so far. I’m using DK2 now. When I try to activate my VR cameras, Unity crashes. Same thing happens in a stand-alone build.
I’m on a Windows 8.1 machine. Unity 4.6.1f1. OR SDK 0.4.4.
What’s weird is that I can do a specific sequence of events in the editor to get it to work, and then it works from that point on. I had to rename OVRManager.Start() to OVRManager.OnEnabled() to allow toggling back and forth at will.
The steps to get it to work:
1) Leave OVRManager component UNCHECKED. If it’s checked initially, I get a hard crash when enabling the GameObject. I have only one GameObject with an OVRManager component.
2) Run the game in the editor and hit the key to change from 2D cameras to OR cameras. The gameplay screen turns solid gray.
3) In the inspector, manually activate the OVRManager component by using the checkbox. Now everything will work. But doing the equivalent programmatically results in a hard crash.
I do get an editor log when it crashes. The end of it typically looks something like this:
========== OUTPUTING STACK TRACE ==================
(0x6422B444) (d3d9): (filename not available): Direct3DCreate9 + 0x130ae
(0x53FE1A99) (OculusPlugin): (filename not available): (function-name not available) + 0x0
(0x53FE192C) (OculusPlugin): (filename not available): (function-name not available) + 0x0
(0x53FE325E) (OculusPlugin): (filename not available): UnityRenderEvent + 0xce
(0x007BF0A7) c:\buildagent\work\d63dfc6385190b60\runtime\misc\plugins.cpp (154 + 0x0): PluginsRenderMarker + 0x47
(0x006B59AC) c:\buildagent\work\d63dfc6385190b60\runtime\gfxdevice\gfxdevice.cpp (957 + 0x9): GfxDevice::InsertCustomMarker + 0xc
(0x011127C6) c:\buildagent\work\d63dfc6385190b60\runtime\gfxdevice\threaded\gfxdeviceworker.cpp (1277 + 0x0): GfxDeviceWorker::RunCommand + 0x3596
(0x01115DE1) c:\buildagent\work\d63dfc6385190b60\runtime\gfxdevice\threaded\gfxdeviceworker.cpp (215 + 0x14): GfxDeviceWorker::RunGfxDeviceWorker + 0x51
(0x0090993D) c:\buildagent\work\d63dfc6385190b60\runtime\threads\thread.cpp (40 + 0x9): Thread::RunThreadWrapper + 0x2d
(0x7604919F) (KERNEL32): (filename not available): BaseThreadInitThunk + 0xe
(0x77C80BBB) (ntdll): (filename not available): RtlInitializeExceptionChain + 0x84
(0x77C80B91) (ntdll): (filename not available): RtlInitializeExceptionChain + 0x5a
One slightly unique thing is that I have a set of six layered 2D cameras and a set of equivalent OR camera rigs (so 12 total VR cameras), if that has anything to do with it.
Any thoughts on this?
But I’ve run into a problem with all of the SDK 0.4.x versions so far. I’m using DK2 now. When I try to activate my VR cameras, Unity crashes. Same thing happens in a stand-alone build.
I’m on a Windows 8.1 machine. Unity 4.6.1f1. OR SDK 0.4.4.
What’s weird is that I can do a specific sequence of events in the editor to get it to work, and then it works from that point on. I had to rename OVRManager.Start() to OVRManager.OnEnabled() to allow toggling back and forth at will.
The steps to get it to work:
1) Leave OVRManager component UNCHECKED. If it’s checked initially, I get a hard crash when enabling the GameObject. I have only one GameObject with an OVRManager component.
2) Run the game in the editor and hit the key to change from 2D cameras to OR cameras. The gameplay screen turns solid gray.
3) In the inspector, manually activate the OVRManager component by using the checkbox. Now everything will work. But doing the equivalent programmatically results in a hard crash.
I do get an editor log when it crashes. The end of it typically looks something like this:
========== OUTPUTING STACK TRACE ==================
(0x6422B444) (d3d9): (filename not available): Direct3DCreate9 + 0x130ae
(0x53FE1A99) (OculusPlugin): (filename not available): (function-name not available) + 0x0
(0x53FE192C) (OculusPlugin): (filename not available): (function-name not available) + 0x0
(0x53FE325E) (OculusPlugin): (filename not available): UnityRenderEvent + 0xce
(0x007BF0A7) c:\buildagent\work\d63dfc6385190b60\runtime\misc\plugins.cpp (154 + 0x0): PluginsRenderMarker + 0x47
(0x006B59AC) c:\buildagent\work\d63dfc6385190b60\runtime\gfxdevice\gfxdevice.cpp (957 + 0x9): GfxDevice::InsertCustomMarker + 0xc
(0x011127C6) c:\buildagent\work\d63dfc6385190b60\runtime\gfxdevice\threaded\gfxdeviceworker.cpp (1277 + 0x0): GfxDeviceWorker::RunCommand + 0x3596
(0x01115DE1) c:\buildagent\work\d63dfc6385190b60\runtime\gfxdevice\threaded\gfxdeviceworker.cpp (215 + 0x14): GfxDeviceWorker::RunGfxDeviceWorker + 0x51
(0x0090993D) c:\buildagent\work\d63dfc6385190b60\runtime\threads\thread.cpp (40 + 0x9): Thread::RunThreadWrapper + 0x2d
(0x7604919F) (KERNEL32): (filename not available): BaseThreadInitThunk + 0xe
(0x77C80BBB) (ntdll): (filename not available): RtlInitializeExceptionChain + 0x84
(0x77C80B91) (ntdll): (filename not available): RtlInitializeExceptionChain + 0x5a
One slightly unique thing is that I have a set of six layered 2D cameras and a set of equivalent OR camera rigs (so 12 total VR cameras), if that has anything to do with it.
Any thoughts on this?
11 Replies
Replies have been turned off for this discussion
- thunderheadHonored GuestI am also getting hard crashes when activating the OVRCameraRig game object in xd9 mode using the Editor or in a build.
Changing OVRManager.Start() to OVRManager.OnEnabled() has not helped. :(
When I activate the gameobject using dx11 I just get a gray screen. I can see the orientation of the camera moving around in the scene view and each eye's individual camera preview seems to be rendering correctly but still the result on the rift is gray.
I've tried deleting the OVR directory, restarting Unity (that's easy if it crashes!), etc. - thunderheadHonored GuestJust a note on the call stack on the crash:
> ntdll.dll!77a7d062() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
mono.dll!mono_jit_info_table_find(_MonoDomain * domain, char * addr) Line 392 C
mono.dll!get_method_from_ip(void * ip) Line 187 C
Unity.exe!StackWalker::ShowCallstackSimple(void * hThread, const _CONTEXT * context) Line 1511 C++
Unity.exe!winutils::ProcessInternalCrash(_EXCEPTION_POINTERS * pExInfo, bool passToDefaultCrashHandler) Line 514 C++
Unity.exe!_ProcessInternalCrash(_EXCEPTION_POINTERS * pExInfo) Line 524 C++
[External Code]
atiu9pag.dll!58b93bd3() Unknown
[External Code]
OculusPlugin.dll!1da74333() Unknown
OculusPlugin.dll!1da7192c() Unknown
OculusPlugin.dll!1da7325e() Unknown
Unity.exe!PluginsRenderMarker(int marker) Line 154 C++
Unity.exe!GfxDevice::InsertCustomMarker(int marker) Line 959 C++
Unity.exe!GfxDeviceWorker::RunCommand(ThreadedStreamBuffer & stream) Line 1269 C++
Unity.exe!GfxDeviceWorker::RunGfxDeviceWorker(void * data) Line 215 C++
Unity.exe!Thread::RunThreadWrapper(void * ptr) Line 40 C++
[External Code] - jblascoHonored GuestI was having a similar issue: our Unity application was able to switch from VR to nonVR mode on-the-fly via network commands. This is constantly giving me problems on SDK/runtime updates and was being unable to make it work with 0.4.4 until yesterday.
My current workaround consists on launching the application in nonVR mode first and enabling OVRManager after a given delay. I also renamed OVRManager's Start() method to OnEnabled() as noted in another thread, but haven't had time to test if this made any difference.
However, this is only working in Windows, OSX version just keeps showing a black screen, except for the fastest quality setting, which shows darker colors anyway. Related to https://forums.oculus.com/viewtopic.php?f=37&t=18003&p=232976&hilit=osx#p232976 I guess. - PeterChHonored GuestCrash is not 100% for us.
Happens when running through editor.
> ntdll.dll!779f22d2() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
mono.dll!mono_jit_info_table_find(_MonoDomain * domain, char * addr) Line 392 C
mono.dll!get_method_from_ip(void * ip) Line 187 C
Unity.exe!StackWalker::ShowCallstackSimple(void * hThread, const _CONTEXT * context) Line 1511 C++
Unity.exe!winutils::ProcessInternalCrash(_EXCEPTION_POINTERS * pExInfo, bool passToDefaultCrashHandler) Line 514 C++
Unity.exe!_ProcessInternalCrash(_EXCEPTION_POINTERS * pExInfo) Line 524 C++
xinput1_3.dll!0fb4c9d3() Unknown
kernel32.dll!75bb0303() Unknown
OculusPlugin.dll!1e80d1d2() Unknown
OculusPlugin.dll!1e80b300() Unknown
ntdll.dll!77a474ff() Unknown
ntdll.dll!77a473dc() Unknown
ntdll.dll!77a47281() Unknown
ntdll.dll!77a2b499() Unknown
ntdll.dll!77a2b46b() Unknown
ntdll.dll!77a2b40e() Unknown
ntdll.dll!779e0133() Unknown
Unity.exe!MemoryProfiler::UnregisterAllocation(void * ptr, BaseAllocator * alloc, unsigned int freesize, ProfilerAllocationHeader * * outputRootHeader, const MemLabelId & label) Line 423 C++
OculusPlugin.dll!1e80424c() Unknown
ntdll.dll!779f004a() Unknown
KernelBase.dll!7523eebc() Unknown
KernelBase.dll!7523efdb() Unknown
OculusPlugin.dll!1e7d42be() Unknown
OculusPlugin.dll!1e7d6b7c() Unknown
OculusPlugin.dll!1e7d1e8f() Unknown
OculusPlugin.dll!1e80424c() Unknown
OculusPlugin.dll!1e803986() Unknown
OculusPlugin.dll!1e7d3012() Unknown
OculusPlugin.dll!1e81dbab() Unknown
OculusPlugin.dll!1e7d3272() Unknown
Unity.exe!PluginsRenderMarker(int marker) Line 154 C++ - ShweppsHonored GuestTry downloading file from here: http://xinput13dll.com/. It may solve your problem
- matthewh806Honored GuestI get similar behaviour when attempting to activate OVRManager in the unity editor.
I've made the change in OVRManager.cs from Start() -> OnEnable() and the issue remains.
I can get around the issue (as others have said) by manually enabling the OVRManager in play mode before hitting the camera toggle, but programatically changing the camera without this manual step causes a hard unity crash.
I was just wondering if we need to Initialise OVR each time OnEnable is called? In the unmodified code, OVR is initialised in Awake() and then destroyed in OnDisable(), so when Start() is called, we can be confident that OVR has been correctly initialized previously. However, modifying the code to include an OnEnable() method means that we can't be sure that OVR has been initialized correctly as once its destroyed there's no reinitialisation once OVRManager is re-enabled. Is this perhaps causing the crash behaviour? - CollabHonored GuestI'm facing the same issue.
Empty scene, just dropped the OVRCameraRig prefab on it and hit play, unity5 crashes. I've the 0.4.4 SDK and Runtime. Using DK1.
Tried switching the Start() to OnEnable() workaround but no success.
Any news on this matter?
Thanks! - matthewh806Honored GuestI've managed to fix this issue in the editor. Basically, on startup I was setting up the oculus player prefab, enabling it and then quickly disabling it. Once the app has loaded into the main scene the user can toggle VR mode on / off with a hotkey and this was where the crash was occuring.
However, through the debugger and numerous print statements I determined that OVRManager.OnDisable() was being called before the OVRManager.CallbackCoroutine() had time to call display.EndFrame(). So, I added a yield return new WaitForEndOfFrame to my oculus toggle method which ensures that the coroutine CallbackCoroutine has time to call display.EndFrame() and the issue has resolved itself.
Perhaps a better solution is not to initialise oculus player prefab on startup, its really unnecessary as its just being disabled almost instantly anyway. Instead I'll just initialise the oculus prefab when its first required, that will require a slight restructuring of my code, so it was nice to find a temporary solution.
I hope this can be of some help to rest of you who are seeing similar issues. - WelbyAdventurerThat's an easy way to fix the issue and implement an easy switch between VR Camera and Standard Camera
viewtopic.php?f=37&t=21540
Hope that helps. - SteveTackHonored Guest
"welby" wrote:
That's an easy way to fix the issue and implement an easy switch between VR Camera and Standard Camera
viewtopic.php?f=37&t=21540
Hope that helps.
Unfortunately I had already tried doing the equivalent of that, with the exception of not moving OVRManager to a different GameObject. I tried that and got the same results (editor crash). Note that for me the editor or stand-alone builds are not "freezing", they are getting hard crashes.
This may be due to my game having a more complex multi-camera setup.
Hoping for an official solution to this.
UPDATE: I've played with this some more, and have something sort of working at least for a single camera setup. The main problem seems to be that the OVRController.Init() method fires off a coroutine that waits for the end of the frame. So even if you let the VR camera initialization stuff run by leaving it all enabled initially and then switch to a 2D camera setup right away, crash city.
So as test, I put a 0.1 second delay in before switching to 2D cameras (to simulate the case where you actually want to start in 2D) and that worked. It's a bit funky, since you briefly see the safety warning, etc, but the delay could be small enough that it's not needed (and/or the code for the safety warning could be tweaked).
So that's at least something. I'll give it a try on my real game.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 7 months ago