Search Unity

DeviceTracker loses orientation when app loses focus (goes into background)

Discussion in 'Vuforia' started by pahe, Sep 27, 2018.

  1. pahe

    pahe

    Joined:
    May 10, 2011
    Posts:
    543
    Hi guys.

    I'm using the extended tracking with the device tracker to position objects in my application. It works fine so long as my mobile app doesn't go into background. When I come back into the app and I'm facing my device into another direction (e.g. I rotated myself by 90°), the device tracker seems to take the new facing for all my objects and moves them around (i.e. they were moved by 90° around in the world).

    I'd expect that the device tracker would recognize where north is and then check that again if the device is facing into a different direction and handle it accordingly, but seems that I'm wrong :)

    How could I preserve the old orientation of the device tracker? I tried to stop the tracker when my app goes into background and start it again when I get into the app again, but that shows the same behaviour. I could reset the device tracker and ask the user kindly to face the device again into the same direction as before and that seems to work, but it's not the best solution.

    Any thoughts about this one? Thanks for help!
     
  2. pahe

    pahe

    Joined:
    May 10, 2011
    Posts:
    543
    I changed my code to the recommended way to:

    Code (CSharp):
    1.  
    2. private void OnApplicationPause(bool pause)
    3. {
    4.     VuforiaBehaviour.Instance.enabled = pause;
    5. }
    Sadly this doesn't fix the problem, but is a very good way to reproduce the issue :) If put into some GUI.Buttons, I can trigger the issue all the time. Pausing the VuforiaBehaviour, then rotating myself and the device and enabling the VuforiaBehaviour again will have all the placed objects displaced.

    Anyone has a suggestion what I can do to prevent that?
     
  3. meedabit

    meedabit

    Official Vuforia Employee Vuforia

    Joined:
    Dec 8, 2016
    Posts:
    266
    Hello,

    To clarify, you're saying that the augmentations move relative to your updated position, rather than staying in their original position affixed to the target you were tracking before backgrounding the app?

    Depending upon your environment, there is the possibility that the map created by the tracker could get confused. The device tracker *does not* use the magnometer, so it does not know cardinal directions. The gyro and accelerometer are used with visual information (aka VIO) to track the environment, so if your in a space where visual features are either limited or are repetitive, there is the potential for the tracker to make a mistake.

    Which version of Unity and Vuforia are you using?

    Thanks,
    Vuforia Engine Support
     
  4. pahe

    pahe

    Joined:
    May 10, 2011
    Posts:
    543
    Hey.

    I'm using Unity 2018.2.11f1 and Vuforia 7.5.20, so latest versions.

    This is the flow with which I reproduce the issue:

    1. Start app and place object. Everything fine:

    2. Disable VuforiaBehaviour (normally I don't do that, but it's the same like when I go with the app into background, either I click a weblink in the app and the browser opens or an iOS prompt shows up like low battery warning or asking for permission) and rotate slightly (I'd say 30°-45°) to the left (there's still free space like the carpet where the chair is standing on):

    3. Enabling VuforiaBehaviour (same as above, the user normally opens the app again or has confirmed the permission,...):

    The placed object has most often disappeared and I have to search for it (this time it was in the wall), it is not always scaled incorrect but sometimes. It is in 95% of the time not at the same place it was before the app has gone into background (or the VuforiaBehaviour has been dis-/enabled). Focussing the marker sometimes help to stabilize the app, but the objects are still misplaced and overall the app seems to jitter more than in the beginning.

    This is pretty crucial for us as we want the user to place his object, then go into a webshop and then come back into the app. First two points are working very nice, last point is the deal breaker at the moment.

    Is there anything we can do to avoid this behaviour or improve the situation?

    Thanks for help.
     
    Last edited: Oct 16, 2018
  5. meedabit

    meedabit

    Official Vuforia Employee Vuforia

    Joined:
    Dec 8, 2016
    Posts:
    266
    Hello,

    Thanks for the detailed description. This use case is particularly challenging considering the nature of the technology. Our Ground Plane feature is based upon VIO (Visual Inertial Odometry) as implemented by ARKit, ARCore or Vuforia VIO. As the name hints, it uses a combination of visual data (from the camera) and inertial data (from the IMU) to find planes, estimate scale and enable tracking. Once the app is backgrounded, the current tracking state is suspended and the data streams from the camera and sensors, all time-aligned with global timestamps, stop coming to the SDK.

    Resuming the app with the camera in the same position as when it was backgrounded *may* result in the Ground Plane experience continuing. Note that Vuforia does not consider this best practice as in our sample we stop the tracker when the app is paused. However, resuming the app with the camera in a different position is adversarial and will result in unexpected behavior, similar to what you're observing. The continuity of the tracking data stopped when the app was paused and now the tracker is "lost".

    Our recommendation is stop the tracker when pausing, and start again when resumed.

    Thanks,
    Vuforia Engine Support
     
    pahe likes this.
  6. pahe

    pahe

    Joined:
    May 10, 2011
    Posts:
    543
    Alright, thank you for your answer. I'm currently experimenting with a mix of ground plane and image target (as a fix anchor point for the user). I noticed that the problem is not present (or at least reduced) when I use the image target. I'm thinking now of putting all my augmented objects below the image target when the app goes into background and unparenting them again when the app comes back again. Not sure if I have to disable the tracker as long as the user hasn't focussed the tracker again though, I'll see.
     
  7. meedabit

    meedabit

    Official Vuforia Employee Vuforia

    Joined:
    Dec 8, 2016
    Posts:
    266
    Good luck!