Search Unity

Question ARFoundation: Use worldmap with ARKit

Discussion in 'AR' started by Stephane-SE, Jul 23, 2020.

  1. Stephane-SE

    Stephane-SE

    Joined:
    Jun 21, 2017
    Posts:
    8
    Hello,
    I have recently migrated to ARFoundation 4.0.2 on Unity 2019.3.3f1.

    On my project, I use worldmap to create AR persistence.
    It was working well until I update ARFoundation.

    I am now facing a strange issue: the first time I launch my app, all seems to perform well (ARSession is correctly started, my image library for tracking is loading well, my worldmap is correctly read from a file and applyed) but I can see in the log that my ARSession is updated several times after I have applied my worldmap.
    The environment is not recognized!

    If I come back to my main menu and reset the tracking (ARSession + imge library + worldmap), this time the environment is recognized.

    Each time I restart my app, the same scenario occurs.

    I think there is an issue the first time due to some ARSession related object not having finished its initialization but I can't find which one and how to check its readyness.
    I tried by adding a small wait (2 seconds): it solves the issue but I am not very pleased to use this kind of solution. There is always a risk that the chosen duration is not enough of some other device.

    Has someone faced the same issue? How did you solve it?

    Thanks for your help


    Remark:
    Here are the logs I have when meeting the bug.
    2020-07-21 14:51:59.744428+0200 AugmentedOperator[509:63122] UnityARKit: Updating ARSession configuration with <ARWorldTrackingConfiguration: 0x2809d92c0 worldAlignment=Gravity lightEstimation=Disabled frameSemantics=None videoFormat=<ARVideoFormat: 0x281f6bb10 imageResolution=(1920, 1440) framesPerSecond=(60)> autoFocus=Enabled environmentTexturing=None wantsHDREnvironmentTextures=Enabled planeDetection=Horizontal|Vertical collaboration=Disabled userFaceTracking=Disabled sceneReconstruction=None [B]initialWorldMap=<ARWorldMap: 0x280ee0750 center=(0.554436 -0.179600 -0.456827) extent=(4.344789 2.186204 2.278459) | 4 anchors, 3064 features>[/B] detectionImages=[<ARReferenceImage: 0x28189ef40 name="D67A9AB0-C6B7-9E47-8C3F-89F80295718B" physicalSize=(0.060, 0.060)>, <ARReferenceImage: 0x281883de0 name="8B3ACE99-2766-9F41-B2D8-E63D17E6EB39" physicalSize=(0.070, 0.070)>] maximumNumberOfTrackedImages=1 automaticImageScaleEstimation=Disabled>
    2020-07-21 14:51:59.765727+0200 AugmentedOperator[509:63122] UnityARKit: Updating ARSession configuration with <ARWorldTrackingConfiguration: 0x2809dcf00 worldAlignment=Gravity lightEstimation=Disabled frameSemantics=None videoFormat=<ARVideoFormat: 0x281f6bb10 imageResolution=(1920, 1440) framesPerSecond=(60)> autoFocus=Enabled environmentTexturing=None wantsHDREnvironmentTextures=Enabled planeDetection=Horizontal|Vertical collaboration=Disabled userFaceTracking=Disabled sceneReconstruction=None detectionImages=[<ARReferenceImage: 0x28189ef40 name="D67A9AB0-C6B7-9E47-8C3F-89F80295718B" physicalSize=(0.060, 0.060)>, <ARReferenceImage: 0x281883de0 name="8B3ACE99-2766-9F41-B2D8-E63D17E6EB39" physicalSize=(0.070, 0.070)>] maximumNumberOfTrackedImages=1 automaticImageScaleEstimation=Disabled>
    2020-07-21 14:51:59.782341+0200 AugmentedOperator[509:63122] UnityARKit: Updating ARSession configuration with <ARWorldTrackingConfiguration: 0x2809c3d80 worldAlignment=Gravity lightEstimation=Disabled frameSemantics=None videoFormat=<ARVideoFormat: 0x281f6bb10 imageResolution=(1920, 1440) framesPerSecond=(60)> autoFocus=Enabled environmentTexturing=None wantsHDREnvironmentTextures=Enabled planeDetection=Horizontal|Vertical collaboration=Disabled userFaceTracking=Disabled sceneReconstruction=None detectionImages=[<ARReferenceImage: 0x28189ef40 name="D67A9AB0-C6B7-9E47-8C3F-89F80295718B" physicalSize=(0.060, 0.060)>, <ARReferenceImage: 0x281883de0 name="8B3ACE99-2766-9F41-B2D8-E63D17E6EB39" physicalSize=(0.070, 0.070)>] maximumNumberOfTrackedImages=1 automaticImageScaleEstimation=Disabled>
    2020-07-21 14:51:59.799017+0200 AugmentedOperator[509:63122] UnityARKit: Updating ARSession configuration with <ARWorldTrackingConfiguration: 0x2809d9080 worldAlignment=Gravity lightEstimation=Disabled frameSemantics=None videoFormat=<ARVideoFormat: 0x281f6bb10 imageResolution=(1920, 1440) framesPerSecond=(60)> autoFocus=Enabled environmentTexturing=None wantsHDREnvironmentTextures=Enabled planeDetection=Horizontal|Vertical collaboration=Disabled userFaceTracking=Disabled sceneReconstruction=None detectionImages=[<ARReferenceImage: 0x28189ef40 name="D67A9AB0-C6B7-9E47-8C3F-89F80295718B" physicalSize=(0.060, 0.060)>, <ARReferenceImage: 0x281883de0 name="8B3ACE99-2766-9F41-B2D8-E63D17E6EB39" physicalSize=(0.070, 0.070)>] maximumNumberOfTrackedImages=1 automaticImageScaleEstimation=Disabled>
    2020-07-21 14:51:59.815714+0200 AugmentedOperator[509:63122] UnityARKit: Updating ARSession configuration with <ARWorldTrackingConfiguration: 0x2809c3f00 worldAlignment=Gravity lightEstimation=Disabled frameSemantics=None videoFormat=<ARVideoFormat: 0x281f6bb10 imageResolution=(1920, 1440) framesPerSecond=(60)> autoFocus=Enabled environmentTexturing=None wantsHDREnvironmentTextures=Enabled planeDetection=Horizontal|Vertical collaboration=Disabled userFaceTracking=Disabled sceneReconstruction=None detectionImages=[<ARReferenceImage: 0x28189ef40 name="D67A9AB0-C6B7-9E47-8C3F-89F80295718B" physicalSize=(0.060, 0.060)>, <ARReferenceImage: 0x281883de0 name="8B3ACE99-2766-9F41-B2D8-E63D17E6EB39" physicalSize=(0.070, 0.070)>] maximumNumberOfTrackedImages=1 automaticImageScaleEstimation=Disabled>


    As you can see, there is a mention to initialWorldmap in the first line but not on the following ones.
     
    Last edited: Jul 23, 2020
  2. Stephane-SE

    Stephane-SE

    Joined:
    Jun 21, 2017
    Posts:
    8
    I repost the sample code in a more readable format.
    Code (CSharp):
    1. 2020-07-21 14:51:59.744428+0200 AugmentedOperator[509:63122] UnityARKit: Updating ARSession configuration with <ARWorldTrackingConfiguration: 0x2809d92c0 worldAlignment=Gravity lightEstimation=Disabled frameSemantics=None videoFormat=<ARVideoFormat: 0x281f6bb10 imageResolution=(1920, 1440) framesPerSecond=(60)> autoFocus=Enabled environmentTexturing=None wantsHDREnvironmentTextures=Enabled planeDetection=Horizontal|Vertical collaboration=Disabled userFaceTracking=Disabled sceneReconstruction=None [B]initialWorldMap=<ARWorldMap: 0x280ee0750 center=(0.554436 -0.179600 -0.456827) extent=(4.344789 2.186204 2.278459) | 4 anchors, 3064 features>[/B] detectionImages=[<ARReferenceImage: 0x28189ef40 name="D67A9AB0-C6B7-9E47-8C3F-89F80295718B" physicalSize=(0.060, 0.060)>, <ARReferenceImage: 0x281883de0 name="8B3ACE99-2766-9F41-B2D8-E63D17E6EB39" physicalSize=(0.070, 0.070)>] maximumNumberOfTrackedImages=1 automaticImageScaleEstimation=Disabled>
    2. 2020-07-21 14:51:59.765727+0200 AugmentedOperator[509:63122] UnityARKit: Updating ARSession configuration with <ARWorldTrackingConfiguration: 0x2809dcf00 worldAlignment=Gravity lightEstimation=Disabled frameSemantics=None videoFormat=<ARVideoFormat: 0x281f6bb10 imageResolution=(1920, 1440) framesPerSecond=(60)> autoFocus=Enabled environmentTexturing=None wantsHDREnvironmentTextures=Enabled planeDetection=Horizontal|Vertical collaboration=Disabled userFaceTracking=Disabled sceneReconstruction=None detectionImages=[<ARReferenceImage: 0x28189ef40 name="D67A9AB0-C6B7-9E47-8C3F-89F80295718B" physicalSize=(0.060, 0.060)>, <ARReferenceImage: 0x281883de0 name="8B3ACE99-2766-9F41-B2D8-E63D17E6EB39" physicalSize=(0.070, 0.070)>] maximumNumberOfTrackedImages=1 automaticImageScaleEstimation=Disabled>
    3. 2020-07-21 14:51:59.782341+0200 AugmentedOperator[509:63122] UnityARKit: Updating ARSession configuration with <ARWorldTrackingConfiguration: 0x2809c3d80 worldAlignment=Gravity lightEstimation=Disabled frameSemantics=None videoFormat=<ARVideoFormat: 0x281f6bb10 imageResolution=(1920, 1440) framesPerSecond=(60)> autoFocus=Enabled environmentTexturing=None wantsHDREnvironmentTextures=Enabled planeDetection=Horizontal|Vertical collaboration=Disabled userFaceTracking=Disabled sceneReconstruction=None detectionImages=[<ARReferenceImage: 0x28189ef40 name="D67A9AB0-C6B7-9E47-8C3F-89F80295718B" physicalSize=(0.060, 0.060)>, <ARReferenceImage: 0x281883de0 name="8B3ACE99-2766-9F41-B2D8-E63D17E6EB39" physicalSize=(0.070, 0.070)>] maximumNumberOfTrackedImages=1 automaticImageScaleEstimation=Disabled>
    4. 2020-07-21 14:51:59.799017+0200 AugmentedOperator[509:63122] UnityARKit: Updating ARSession configuration with <ARWorldTrackingConfiguration: 0x2809d9080 worldAlignment=Gravity lightEstimation=Disabled frameSemantics=None videoFormat=<ARVideoFormat: 0x281f6bb10 imageResolution=(1920, 1440) framesPerSecond=(60)> autoFocus=Enabled environmentTexturing=None wantsHDREnvironmentTextures=Enabled planeDetection=Horizontal|Vertical collaboration=Disabled userFaceTracking=Disabled sceneReconstruction=None detectionImages=[<ARReferenceImage: 0x28189ef40 name="D67A9AB0-C6B7-9E47-8C3F-89F80295718B" physicalSize=(0.060, 0.060)>, <ARReferenceImage: 0x281883de0 name="8B3ACE99-2766-9F41-B2D8-E63D17E6EB39" physicalSize=(0.070, 0.070)>] maximumNumberOfTrackedImages=1 automaticImageScaleEstimation=Disabled>
    5. 2020-07-21 14:51:59.815714+0200 AugmentedOperator[509:63122] UnityARKit: Updating ARSession configuration with <ARWorldTrackingConfiguration: 0x2809c3f00 worldAlignment=Gravity lightEstimation=Disabled frameSemantics=None videoFormat=<ARVideoFormat: 0x281f6bb10 imageResolution=(1920, 1440) framesPerSecond=(60)> autoFocus=Enabled environmentTexturing=None wantsHDREnvironmentTextures=Enabled planeDetection=Horizontal|Vertical collaboration=Disabled userFaceTracking=Disabled sceneReconstruction=None detectionImages=[<ARReferenceImage: 0x28189ef40 name="D67A9AB0-C6B7-9E47-8C3F-89F80295718B" physicalSize=(0.060, 0.060)>, <ARReferenceImage: 0x281883de0 name="8B3ACE99-2766-9F41-B2D8-E63D17E6EB39" physicalSize=(0.070, 0.070)>] maximumNumberOfTrackedImages=1 automaticImageScaleEstimation=Disabled>
     
  3. tcolette

    tcolette

    Joined:
    Sep 9, 2021
    Posts:
    1
    Hello Stephane, I am facing the same problem and haven't found any viable solution yet...
    Were you able to fix yours in some way?

    Thanks a lot in advance
     
  4. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062