Search Unity

Scene loading issue (hang) on Android/AR Foundation

Discussion in 'AR' started by Saicopate, Aug 22, 2018.

  1. Saicopate

    Saicopate

    Joined:
    Sep 25, 2017
    Posts:
    76
    Hi!
    I am having this bug for some time now (from the start of using AR Foundation) - still waiting for solution:

    When switching from AR-enabled scene to a different scene the app hangs for ca. 10 seconds and then loads the next scene ok.

    This happens on Android only, same app on iOS works fine and takes nearly no time to switch scenes.
    To me it seems like it has to do with executing onDisable code on some AR components but it gets very nasty in terms of user experience on Android.

    Tried on many Unity versions, currently 2018.2.4f1
    Also with all AR Foundation versions up to now (v.17).
    Android 8.0 on Samsung S8.

    Easy to reproduce by simply adding a button in one of AR Foundation Samples scenes to switch to a different scene.

    I reported a bug some time ago together with reproduction project, but updates do not seem to cover this.
    Any help would be appreciated.
     
  2. tdmowrer

    tdmowrer

    Joined:
    Apr 21, 2017
    Posts:
    605
    The issue you reported (case ID: 1051049) was described as (paraphrashing): Unity hangs for a moment, then leaks memory. The memory leak was the focus of the bug and has been fixed in Unity (2018.2.3f1 if memory serves). I have not seen a 10 second hang on scene switching (scene switching is something I test regularly). I'll take another look, though.

    Have you tried connecting the profiler to see what it's doing for 10 seconds?
     
  3. Saicopate

    Saicopate

    Joined:
    Sep 25, 2017
    Posts:
    76
    The bug was indeed fixed so it does not appear in Android Monitor any more but the behavior remains the same.

    Have look here:

     
    Last edited: Aug 23, 2018
    Apadmi likes this.
  4. tdmowrer

    tdmowrer

    Joined:
    Apr 21, 2017
    Posts:
    605
    I took another look at this, and timed the actual C call we make to ARCore to disable the session. Just about all the time for ARSession.OnDestroy is taken up this one C call, about 500ms on a Pixel and an S8+, so it is rather expensive. However, it's much less than the 10 seconds you reported. I also tested in the project you attached to case 1051049 and saw the same timings. Is the timing you reported above using the same project or similar, i.e., just a simple AR scene?
     
  5. Saicopate

    Saicopate

    Joined:
    Sep 25, 2017
    Posts:
    76
    The above log was from switching scenes (SampleScene -> LightEstimation) within AR Foundation Samples package from Git. But with all AR Foundation projects it is always the same.
    I also tried building from different computer (Mac) and it is the same.

    Before AR Foundation I was using ARInterface and switching scenes was working ok.
    If there's anything more I can check or log please let me know.

    If anyone else having Samsung S8 and seeing this, can check if switching from AR-enabled scene to a different scene is causing a ~ 8-10s lag - would be really great. ;)
     
  6. Saicopate

    Saicopate

    Joined:
    Sep 25, 2017
    Posts:
    76
    Finally this has been fixed with 2018.2.10 and AR Foundation v.18. Thanks :)
     
    whogas likes this.
  7. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    I am having the same problem...

    I was using 2018.2.6 with AR Foundation v.17... building to S8.

    Using ARFoundation samples project, added a menu scene with single button to load into SampleScene... and a button to go back. 5+sec lag after button press going from SampleScene to menu.

    Updating to AR Foundation v.18 has not solved the problem.

    Will upgrade to 2018.2.10 and keep you posted.
    Cheers
     
    ROBYER1 likes this.
  8. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    Upgrading to 2018.2.10 has not fixed the lag. Its anything between 5-8 secs. and doesnt seem to be proportional to the number of trackables detected.

    @Saicopate Can I ask if you made any other changes after upgrading to 2018.2.10 and updating to v18 ARFoundation? Any new build settings etc?

    Cheers
     
  9. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    Here's the profiler output
     

    Attached Files:

  10. Saicopate

    Saicopate

    Joined:
    Sep 25, 2017
    Posts:
    76
    Looking at your profiler output, it's the same problem that I had on my S8.
    One more thing that I have done was updating ARCore package to the latest.
    I am sure that everything else remained the same and the problem was fixed.
     
  11. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    I'm on ARCore preview.19... You on that too yeah?

    Can't see any deeper than those ARSession Disable and Destroy calls running the Stop and Destroy Subsystems via the ARSubsystemManager.

    Cheers
     
  12. Saicopate

    Saicopate

    Joined:
    Sep 25, 2017
    Posts:
    76
    Yes, I'm on ARcore v.19.
     
  13. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    Are you building on Windows or Mac? (I know, I'm clutching at straws now!)
     
  14. Saicopate

    Saicopate

    Joined:
    Sep 25, 2017
    Posts:
    76
    Both. And both were bugged until recently.
     
    ROBYER1 likes this.