Search Unity

Bug ARFoundation 4.1.1 – Status Reports "Tracking" after Denying Camera Access

Discussion in 'AR' started by HulloImJay, Jan 15, 2021.

  1. HulloImJay

    HulloImJay

    Joined:
    Mar 26, 2012
    Posts:
    89
    Hello there. This is a little redundant with a report I'm sending through the Unity Bug Reporter, but I wanted to make sure it landed in front of the ARF team and had a place for discussion.

    1. What happened

    When asking for camera permission on the first run (fresh app install), if the user taps "Don't Allow" then camera permission is not granted but ARFoundation reports both the tracking state and session state as tracking. It probably goes without saying why this is a problem.

    2. How we can reproduce it

    Via the Unity Bug Reporter I attached a full project, but essentially it's just ARF and this one script:

    Code (CSharp):
    1. [SerializeField]
    2. ARSession aRSession;
    3.  
    4. TrackingState lastTrackingState;
    5. NotTrackingReason lastNotTrackingReason;
    6.  
    7. void Update () {
    8.     if (aRSession.subsystem == null)
    9.         return;
    10.  
    11.     if (aRSession.subsystem.trackingState == TrackingState.Tracking) {
    12.         if (lastTrackingState != TrackingState.Tracking) {
    13.             Debug.LogWarningFormat ("Tracking Started" +
    14.                 "\n• tracking state:{0}\n• session state: {1}.", aRSession.subsystem.trackingState, ARSession.state);
    15.         }
    16.     } else if (aRSession.subsystem.trackingState == TrackingState.Limited) {
    17.         // Display one of our problem states if tracking just stopped or if the reason changed.
    18.         if (lastTrackingState == TrackingState.Tracking || lastNotTrackingReason !=           aRSession.subsystem.notTrackingReason) {
    19.            Debug.LogFormat ("Tracking Limited" +
    20.                "\n• tracking state:{0}\n• session state: {1}.", aRSession.subsystem.trackingState, ARSession.state);
    21.          }
    22.  
    23.     } else if (aRSession.subsystem.trackingState == TrackingState.None) {
    24.         if (lastTrackingState != TrackingState.None) {
    25.            Debug.LogFormat ("Not Tracking" +
    26.                 "\n• tracking state:{0}\n• session state: {1}.", aRSession.subsystem.trackingState, ARSession.state);
    27.         }
    28.     }
    29.     lastTrackingState = aRSession.subsystem.trackingState;
    30.     lastNotTrackingReason = aRSession.subsystem.notTrackingReason;
    31. }
    32.  
    As soon as the ARSession object becomes active (mine starts disabled) you get the camera permission prompt. If you tap "Don't Allow" then the above script will spit out the log about tracking having started, where one might expect session and tracking states to be "None" or something like that.

    Frequency: Most of the time. (I've had it NOT happen once in a series of a dozen tests.)
    ARFoundation 4.1.1
    Unity 2020.1.11f1 (also confirmed in Unity 2019.4.16f1)
    iPhone 12 Pro Max
    iOS 14.2.1
     
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,822
    Team would like you to file a bug report for us.
     
  3. HulloImJay

    HulloImJay

    Joined:
    Mar 26, 2012
    Posts:
    89
    Like I said above, I've submitted a bug report already and posted it here to make sure it came to the attention of the right folks :)
     
    TreyK-47 likes this.
  4. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,822
    Whoops! Looks like you did! Thank you for that, and apologies for missing that bit. :)
     
    HulloImJay likes this.
  5. HulloImJay

    HulloImJay

    Joined:
    Mar 26, 2012
    Posts:
    89