Search Unity

ARKit coaching overlay remains active after switching scenes

Discussion in 'AR' started by smartinetz, Jan 14, 2020.

  1. smartinetz

    smartinetz

    Joined:
    Dec 8, 2017
    Posts:
    49
    Hey guys,

    I am currently working on a new AR App using ARFoundation 3.1.0 preview3. I am developing for ARKit and use the coaching overlay to have some onscreen explaination for my users what to do next. So far so good...

    At some point the user can switch from the AR scene to another non-AR scene. Before this new scene is loaded, I make sure to turn off the coaching overlay, reset and then disable the session. The Problem I have is, if the overlay is visible and the user switches to the non-AR scene by clicking thru the overlay, parts of it remain visible and the user has to restart the App because this never disappears

    IMG_0033.PNG IMG_0034.PNG

    This looks to me like a bug but if anybody has a suggestion how to fix it, bring it on.

    Thanks
     
    mrtorrent likes this.
  2. Sky77

    Sky77

    Joined:
    Jan 30, 2014
    Posts:
    171
    We had the same problem, make sure you wait some time between disabling the overlay and closing the ARKit session, so the overlay is properly dismissed.
    If you disable the overlay and stop or destroy the session in the same frame you’ll get the error that you’re seeing.
     
    smartinetz likes this.
  3. smartinetz

    smartinetz

    Joined:
    Dec 8, 2017
    Posts:
    49
    Thanks for the hint.. even though I hope this can be fixed in future releases. ;)
     
  4. Sky77

    Sky77

    Joined:
    Jan 30, 2014
    Posts:
    171
    Yes... What we've seen is that there's a lot of asynchronous stuff going on in the ARKit native plugin, and if you just stop and destroy the session you can get some weird behaviour.
     
    smartinetz likes this.
  5. smartinetz

    smartinetz

    Joined:
    Dec 8, 2017
    Posts:
    49
    Sad enough, I tried now pretty much every trick in the book using Task.Delay before after and in between turning off the coaching overlay. This only works to some extend but most of the time there's still a dimmed screen and some text left over in the scene I switch to. :(

    Code (CSharp):
    1. CoachingOverlay(false);
    2. await Task.Delay(2000);
    3. arSession.Reset();
    4. await Task.Delay(2000);
    5. arSession.enabled = false;
    6. await Task.Delay(2000);
    Really annoying!!!
     
  6. smartinetz

    smartinetz

    Joined:
    Dec 8, 2017
    Posts:
    49
    I found the real problem. The class ARKitCoachingOverlay which I used to implement my coaching overlay is missing a method to deactivate the coaching completely. Once I changed that, the overlay is finally behaving!!!

    Code (CSharp):
    1. public void DeactivateCoaching()
    2.     {
    3. #if UNITY_IOS
    4.         if (supported && GetComponent<ARSession>().subsystem is ARKitSessionSubsystem sessionSubsystem)
    5.         {
    6.             sessionSubsystem.SetCoachingActive(false, ARCoachingOverlayTransition.Instant);
    7.         }
    8.         else
    9. #endif
    10.         {
    11.             throw new NotSupportedException("ARCoachingOverlay is not supported");
    12.         }
    13.     }
     
    mrtorrent likes this.