"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

Access violation when enabling Vuforia in Unity

Hey everyone,

We are currently working on our first HoloLens project as part of a student thesis. Our goal is an application that is capable of presenting the user a possible use case with HoloLens within the retail market segment. The app uses both VuMarks and Image Targets in order to recognize and locate real world objects like products or shop inventory. However, getting close to the end of our project, we are still struggling with a hard to reproduce, but randomly reocurring "crash to desktop" in our app. We spent hours of debugging, no luck so far in finding the root cause of this issue. All we can see is that the crash dumps indicate an access violation exception in Vuforia.dll.

Attached dump files show: Unhandled exception at 0x60AA6BA0 (Vuforia.dll) in ...exe.1084.dmp: 0xC0000005: Access violation reading location 0x1171CA44  

The Visual Studio debugger just stops  as soon as the error occurs, we never get the chance to gather any more details (e.g. callstack or the like). Same with the Unity profiler, it doesn't crash but we weren't able to spot anything fishy when analyzing the list of running scripts just before the crash occured.

Luckily, the crash occurs at the same point(s) in our application

  1. User enters mode that requires image recognition
  2. We enable Vuforia using vuforiaCamera.SetActive(true); with"vuforiaCamera" being a reference to our ARCamera game object
  3. Now this is where it gets a little bit tricky, our app either continues working totally fine, crashes right after detecting one of our VuMarks / Image Targets or it crashes with a little delay after first detection (e.g. right after targets gets out of users sight)
  4. Result after crash is always the same: Crash dump with access violation
  5. If the app didn't crash, we disable Vuforia with vuforiaCamera.SetActive(false); after user has left mode that required image recognition

Vuforia is also enabled right after startup, but we didn't observe similar crashes at that point. 

Do you see any problems in

  • Enabling/Disabling Vuforia during runtime?
  • Attaching child objects to the Vuforia target game objects (i.e. something like a visual detection indicator)?
  • Using Vuforia in combination with spatial anchors (i.e. to anchor detected targets)
  • Removing the ARCamera behavior that overwrites the Unity target framerate (as far as we know HoloLens caps the framerate to 30 anyway when the camera is accessed)?
  • Executing a fair amount of code inside the trackable state event listeners (we didn't verify whether events are directly fired from within Vuforia.dll)
  • Looking at targets within a specific timeframe after enabling Vuforia?

Here's our setup:

  • HoloLens (Windows version 14393.1198.x86fre.rs1_release_sec.170427-1353)
  • Unity v5.5.2f1
  • Vuforia v6.2.10 (latest from your website)
  • HoloToolkit v1.5.6.0
  • All our scripts are written in C#

We register for trackable state changes of VuMarks and image targets with

        public void RegisterForTracking(GameObject trackableObject)         {             var eventListener = new TrackableEventListener(trackableObject);             eventListener.OnTrackableStateChanged += OnTrackableStateChanged;         }           private void OnTrackableStateChanged(TrackableBehaviour source,             TrackableBehaviour.Status previousStatus,             TrackableBehaviour.Status newStatus)         {             if (newStatus == TrackableBehaviour.Status.DETECTED ||                 newStatus == TrackableBehaviour.Status.TRACKED ||                 newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED)             {                 OnTrackableDetected(source);             }             else             {                 OnTrackableLost(source);             }         }

We attached three HoloLens dumps from consecutive crashes to this post since we are really running out of ideas on our side. So we decided to ask you guys for a little help. Maybe you can get more information out of the dump file when including the required symbol files for Vuforia.dll.

 

Looking forward to hearing from you.

Hello,

Thanks for reaching out. We'll start by taking a look at the dumps to see if there are any indicators.

I will respond to this thread with any findings and/or requests.

Hello,

We took a look at the dumps but unfortunately it doesn't provide enough information as there is no heap or stack information. We also tried to debug with the mini dump and it looks like there is an exception, but again we are having difficulties isolating.

Was this issue ever resolved?  I'm running into the same thing.  Trying to create a hololens project in unity.  I've tried with unity 2017.2.1f1, 2017.3.1f1, and 2018.1.0f2.  I'm importing Microsoft's mixed reality toolkit, and setting up the project and a scene with just a si