Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question MARS scenes don't work the second time I load them

Discussion in 'Unity MARS' started by alb-lab, May 16, 2021.

  1. alb-lab

    alb-lab

    Joined:
    Feb 2, 2019
    Posts:
    11
    Hi everybody!
    I'm working on a very simple MARS app.
    There are 3 scenes:
    1 - A simple menu to choose one of the other 2 scenes
    2 - An AR scene with one ImageMarker that triggers the display of some prefabs
    3 - An AR scene with face tracking, to show some prefab around the face of the user

    The app works well on Android phones but on iOS only the first executed AR scene works well. If I return to the menu and choose the other scene (or the same scene) it doesn't work anymore.

    In other words consider the following sequence:
    - Execute the app
    - In the menu choose scene 2 or scene 3, it works well
    - Return to the menu (there's a button for this action)
    - Choose scene 2 or scene 3, it doesn't work.

    Any suggestion ?
    Thank you in advance.
     
  2. alb-lab

    alb-lab

    Joined:
    Feb 2, 2019
    Posts:
    11
    This is the log output.
    As you can see the sequence of scenes is:
    Menu -> Scene2 -> Menu -> Scene2

    Code (log):
    1. 2021-05-16 19:47:21.174711+0200 TerraIgnota[2118:1344572] Built from '2020.2/staging' branch, Version '2020.2.3f1 (8ff31bc5bf5b)', Build type 'Release', Scripting Backend 'il2cpp'
    2. 2021-05-16 19:47:21.175947+0200 TerraIgnota[2118:1344572] MemoryManager: Using 'Default' Allocator.
    3. -> applicationDidFinishLaunching()
    4. -> applicationDidBecomeActive()
    5. [Subsystems] Discovering subsystems at path /private/var/containers/Bundle/Application/9B6FCD4F-FFE1-4EFD-BD0F-A296311F0376/TerraIgnota.app/Data/UnitySubsystems
    6. [Subsystems] No descriptors matched for    examples in UnitySubsystems/UnityARKit/UnitySubsystemsManifest.json.
    7. [Subsystems] 1 'inputs' descriptors matched in UnitySubsystems/UnityARKit/UnitySubsystemsManifest.json
    8. [Subsystems] No descriptors matched for    displays in UnitySubsystems/UnityARKit/UnitySubsystemsManifest.json.
    9. [Subsystems] 1 'meshings' descriptors matched in UnitySubsystems/UnityARKit/UnitySubsystemsManifest.json
    10. GfxDevice: creating device client; threaded=1
    11. Initializing Metal device caps: Apple A12Z GPU
    12. Initialize engine version: 2020.2.3f1 (8ff31bc5bf5b)
    13. XRGeneral Settings awakening...
    14. UnityEngine.XR.Management.XRGeneralSettings:Awake()
    15.  
    16. 2021-05-16 19:47:22.489470+0200 TerraIgnota[2118:1344572]
    17.         // 2D joint skeleton
    18.         enum JointIndices
    19.         {
    20.                 Invalid = -1,
    21.                 Head = 0, // parent: Neck1 [1]
    22.                 Neck1 = 1, // parent: Root [16]
    23.                 RightShoulder1 = 2, // parent: Neck1 [1]
    24.                 RightForearm = 3, // parent: RightShoulder1 [2]
    25.                 RightHand = 4, // parent: RightForearm [3]
    26.                 LeftShoulder1 = 5, // parent: Neck1 [1]
    27.                 LeftForearm = 6, // parent: LeftShoulder1 [5]
    28.                 LeftHand = 7, // parent: LeftForearm [6]
    29.                 RightUpLeg = 8, // parent: Root [16]
    30.                 RightLeg = 9, // parent: RightUpLeg [8]
    31.                 RightFoot = 10, // parent: RightLeg [9]
    32.                 LeftUpLeg = 11, // parent: Root [16]
    33.                 LeftLeg = 12, // parent: LeftUpLeg [11]
    34.                 LeftFoot = 13, // parent: LeftLeg [12]
    35.                 RightEye = 14, // parent: Head [0]
    36.                 LeftEye = 15, // parent: Head [0]
    37.                 Root = 16, // parent: <none> [-1]
    38.         }
    39. 2021-05-16 19:47:22.494524+0200 TerraIgnota[2118:1344572]
    40.         // 3D joint skeleton
    41.         enum JointIndices
    42.         {
    43.                 Invalid = -1,
    44.                 Root = 0, // parent: <none> [-1]
    45.                 Hips = 1, // parent: Root [0]
    46.                 LeftUpLeg = 2, // parent: Hips [1]
    47.                 LeftLeg = 3, // parent: LeftUpLeg [2]
    48.                 LeftFoot = 4, // parent: LeftLeg [3]
    49.                 LeftToes = 5, // parent: LeftFoot [4]
    50.                 LeftToesEnd = 6, // parent: LeftToes [5]
    51.                 RightUpLeg = 7, // parent: Hips [1]
    52.                 RightLeg = 8, // parent: RightUpLeg [7]
    53.                 RightFoot = 9, // parent: RightLeg [8]
    54.                 RightToes = 10, // parent: RightFoot [9]
    55.                 RightToesEnd = 11, // parent: RightToes [10]
    56.                 Spine1 = 12, // parent: Hips [1]
    57.                 Spine2 = 13, // parent: Spine1 [12]
    58.                 Spine3 = 14, // parent: Spine2 [13]
    59.                 Spine4 = 15, // parent: Spine3 [14]
    60.                 Spine5 = 16, // parent: Spine4 [15]
    61.                 Spine6 = 17, // parent: Spine5 [16]
    62.                 Spine7 = 18, // parent: Spine6 [17]
    63.                 LeftShoulder1 = 19, // parent: Spine7 [18]
    64.                 LeftArm = 20, // parent: LeftShoulder1 [19]
    65.                 LeftForearm = 21, // parent: LeftArm [20]
    66.                 LeftHand = 22, // parent: LeftForearm [21]
    67.                 LeftHandIndexStart = 23, // parent: LeftHand [22]
    68.                 LeftHandIndex1 = 24, // parent: LeftHandIndexStart [23]
    69.                 LeftHandIndex2 = 25, // parent: LeftHandIndex1 [24]
    70.                 LeftHandIndex3 = 26, // parent: LeftHandIndex2 [25]
    71.                 LeftHandIndexEnd = 27, // parent: LeftHandIndex3 [26]
    72.                 LeftHandMidStart = 28, // parent: LeftHand [22]
    73.                 LeftHandMid1 = 29, // parent: LeftHandMidStart [28]
    74.                 LeftHandMid2 = 30, // parent: LeftHandMid1 [29]
    75.                 LeftHandMid3 = 31, // parent: LeftHandMid2 [30]
    76.                 LeftHandMidEnd = 32, // parent: LeftHandMid3 [31]
    77.                 LeftHandPinkyStart = 33, // parent: LeftHand [22]
    78.                 LeftHandPinky1 = 34, // parent: LeftHandPinkyStart [33]
    79.                 LeftHandPinky2 = 35, // parent: LeftHandPinky1 [34]
    80.                 LeftHandPinky3 = 36, // parent: LeftHandPinky2 [35]
    81.                 LeftHandPinkyEnd = 37, // parent: LeftHandPinky3 [36]
    82.                 LeftHandRingStart = 38, // parent: LeftHand [22]
    83.                 LeftHandRing1 = 39, // parent: LeftHandRingStart [38]
    84.                 LeftHandRing2 = 40, // parent: LeftHandRing1 [39]
    85.                 LeftHandRing3 = 41, // parent: LeftHandRing2 [40]
    86.                 LeftHandRingEnd = 42, // parent: LeftHandRing3 [41]
    87.                 LeftHandThumbStart = 43, // parent: LeftHand [22]
    88.                 LeftHandThumb1 = 44, // parent: LeftHandThumbStart [43]
    89.                 LeftHandThumb2 = 45, // parent: LeftHandThumb1 [44]
    90.                 LeftHandThumbEnd = 46, // parent: LeftHandThumb2 [45]
    91.                 Neck1 = 47, // parent: Spine7 [18]
    92.                 Neck2 = 48, // parent: Neck1 [47]
    93.                 Neck3 = 49, // parent: Neck2 [48]
    94.                 Neck4 = 50, // parent: Neck3 [49]
    95.                 Head = 51, // parent: Neck4 [50]
    96.                 Jaw = 52, // parent: Head [51]
    97.                 Chin = 53, // parent: Jaw [52]
    98.                 LeftEye = 54, // parent: Head [51]
    99.                 LeftEyeLowerLid = 55, // parent: LeftEye [54]
    100.  
    101.                 LeftEyeUpperLid = 56, // parent: LeftEye [54]
    102.                 LeftEyeball = 57, // parent: LeftEye [54]
    103.                 Nose = 58, // parent: Head [51]
    104.                 RightEye = 59, // parent: Head [51]
    105.                 RightEyeLowerLid = 60, // parent: RightEye [59]
    106.                 RightEyeUpperLid = 61, // parent: RightEye [59]
    107.                 RightEyeball = 62, // parent: RightEye [59]
    108.                 RightShoulder1 = 63, // parent: Spine7 [18]
    109.                 RightArm = 64, // parent: RightShoulder1 [63]
    110.                 RightForearm = 65, // parent: RightArm [64]
    111.                 RightHand = 66, // parent: RightForearm [65]
    112.                 RightHandIndexStart = 67, // parent: RightHand [66]
    113.                 RightHandIndex1 = 68, // parent: RightHandIndexStart [67]
    114.                 RightHandIndex2 = 69, // parent: RightHandIndex1 [68]
    115.                 RightHandIndex3 = 70, // parent: RightHandIndex2 [69]
    116.                 RightHandIndexEnd = 71, // parent: RightHandIndex3 [70]
    117.                 RightHandMidStart = 72, // parent: RightHand [66]
    118.                 RightHandMid1 = 73, // parent: RightHandMidStart [72]
    119.                 RightHandMid2 = 74, // parent: RightHandMid1 [73]
    120.                 RightHandMid3 = 75, // parent: RightHandMid2 [74]
    121.                 RightHandMidEnd = 76, // parent: RightHandMid3 [75]
    122.                 RightHandPinkyStart = 77, // parent: RightHand [66]
    123.                 RightHandPinky1 = 78, // parent: RightHandPinkyStart [77]
    124.                 RightHandPinky2 = 79, // parent: RightHandPinky1 [78]
    125.                 RightHandPinky3 = 80, // parent: RightHandPinky2 [79]
    126.                 RightHandPinkyEnd = 81, // parent: RightHandPinky3 [80]
    127.                 RightHandRingStart = 82, // parent: RightHand [66]
    128.                 RightHandRing1 = 83, // parent: RightHandRingStart [82]
    129.                 RightHandRing2 = 84, // parent: RightHandRing1 [83]
    130.                 RightHandRing3 = 85, // parent: RightHandRing2 [84]
    131.                 RightHandRingEnd = 86, // parent: RightHandRing3 [85]
    132.                 RightHandThumbStart = 87, // parent: RightHand [66]
    133.                 RightHandThumb1 = 88, // parent: RightHandThumbStart [87]
    134.                 RightHandThumb2 = 89, // parent: RightHandThumb1 [88]
    135.                 RightHandThumbEnd = 90, // parent: RightHandThumb2 [89]
    136.         }
    137. [Subsystems] Loading plugin UnityARKit for subsystem ARKit-Input...
    138. [Subsystems] UnityARKit successfully registered Provider for ARKit-Input
    139. [Subsystems] UnityARKit successfully registered Provider for ARKit-Input
    140. [Subsystems] UnityARKit successfully registered Provider for ARKit-Meshing
    141. [Subsystems] Loading plugin UnityARKit for subsystem ARKit-Meshing...
    142. 2021-05-16 19:47:22.849763+0200 TerraIgnota[2118:1344572] Unbalanced calls to begin/end appearance transitions for <UnityViewControllerStoryboard: 0x13bf31b70>.
    143. UnloadTime: 3.597875 ms
    144. Unloading 6 Unused Serialized files (Serialized files now loaded: 0)
    145. UnloadTime: 0.697000 ms
    146.  
    147. Unloading 8 unused Assets to reduce memory usage. Loaded Objects now: 18375.
    148. Total: 5.530167 ms (FindLiveObjects: 0.551458 ms CreateObjectMapping: 0.045917 ms MarkObjects: 4.879792 ms    DeleteObjects: 0.052458 ms)
    149.  
    150.  
    151. ----> LOAD SCENE 2 <----
    152.  
    153.  
    154. Unloading 7 Unused Serialized files (Serialized files now loaded: 0)
    155. UnloadTime: 11.567958 ms
    156. MARS GeoLocation is not configured to request location service permission for this project. See 'GeoLocationModule' asset.
    157. Unity.MARS.Providers.GeoLocationModule:Unity.XRTools.ModuleLoader.IModule.LoadModule()
    158. Unity.XRTools.ModuleLoader.ModuleLoaderCore:LoadModulesWithTypes(List`1)
    159. Unity.MARS.MARSSession:Awake()
    160.  
    161.  
    162. Unloading 60 unused Assets to reduce memory usage. Loaded Objects now: 129196.
    163. Total: 10.376042 ms (FindLiveObjects: 4.189208 ms CreateObjectMapping: 0.104667 ms MarkObjects: 5.307167 ms    DeleteObjects: 0.774208 ms)
    164.  
    165. 2021-05-16 19:47:56.239567+0200 TerraIgnota[2118:1344572] UnityARKit: Updating ARSession configuration with <ARWorldTrackingConfiguration: 0x280869c30 worldAlignment=Gravity lightEstimation=Disabled frameSemantics=None videoFormat=<ARVideoFormat: 0x281e481e0 imageResolution=(1920, 1440) framesPerSecond=(60)> autoFocus=Enabled environmentTexturing=None wantsHDREnvironmentTextures=Enabled planeDetection=None collaboration=Disabled userFaceTracking=Disabled sceneReconstruction=None detectionImages=[<ARReferenceImage: 0x281b22580 name="TerraIgnotaImgMarker_6013055B-BD03-CD4E-869C-DFE943A91076" physicalSize=(1.000, 1.000)>] maximumNumberOfTrackedImages=4 automaticImageScaleEstimation=Disabled appClipCodeTracking=Disabled>
    166.  
    167.  
    168. ----> LOAD MENU SCENE <----
    169.  
    170.  
    171. UnityEngine.Events.UnityAction:Invoke()
    172. UnityEngine.Events.UnityEvent:Invoke()
    173. UnityEngine.EventSystems.EventFunction`1:Invoke(T1, BaseEventData)
    174. UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    175. UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean)
    176. UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents()
    177. UnityEngine.EventSystems.StandaloneInputModule:Process()
    178.  
    179. Unloading 5 Unused Serialized files (Serialized files now loaded: 0)
    180. UnloadTime: 124.216667 ms
    181.  
    182. Unloading 112 unused Assets to reduce memory usage. Loaded Objects now: 18469.
    183. Total: 7.918667 ms (FindLiveObjects: 0.518625 ms CreateObjectMapping: 0.043500 ms MarkObjects: 5.665208 ms    DeleteObjects: 1.690750 ms)
    184.  
    185.  
    186. ----> LOAD SCENE 2 <----
    187.  
    188. Unloading 7 Unused Serialized files (Serialized files now loaded: 0)
    189. UnloadTime: 12.749250 ms
    190. MARS GeoLocation is not configured to request location service permission for this project. See 'GeoLocationModule' asset.
    191. Unity.MARS.Providers.GeoLocationModule:Unity.XRTools.ModuleLoader.IModule.LoadModule()
    192. Unity.XRTools.ModuleLoader.ModuleLoaderCore:LoadModulesWithTypes(List`1)
    193. Unity.MARS.MARSSession:Awake()
    194.  
    195. 2021-05-16 19:48:28.843521+0200 TerraIgnota[2118:1344572] UnityARKit: Updating ARSession configuration with <ARWorldTrackingConfiguration: 0x280806f70 worldAlignment=Gravity lightEstimation=Disabled frameSemantics=None videoFormat=<ARVideoFormat: 0x281e481e0 imageResolution=(1920, 1440) framesPerSecond=(60)> autoFocus=Enabled environmentTexturing=None wantsHDREnvironmentTextures=Enabled planeDetection=None collaboration=Disabled userFaceTracking=Disabled sceneReconstruction=None detectionImages=[<ARReferenceImage: 0x281b22580 name="TerraIgnotaImgMarker_6013055B-BD03-CD4E-869C-DFE943A91076" physicalSize=(1.000, 1.000)>] maximumNumberOfTrackedImages=4 automaticImageScaleEstimation=Disabled appClipCodeTracking=Disabled>
    196.  
    197. Unloading 61 unused Assets to reduce memory usage. Loaded Objects now: 129196.
    198. Total: 9.701417 ms (FindLiveObjects: 3.863833 ms CreateObjectMapping: 0.090167 ms MarkObjects: 5.294500 ms    DeleteObjects: 0.452292 ms)
    199.  
    200. -> applicationWillResignActive()
    201. -> applicationDidEnterBackground()
    202.  
    203.  
     
  3. CiaranWills

    CiaranWills

    Unity Technologies

    Joined:
    Apr 24, 2020
    Posts:
    151
    This is an issue that has come up before for iOS; we're looking into it but a workaround is to reset the session when changing scenes:
    Code (CSharp):
    1. ARFoundationSessionProvider.currentSession?.Reset();
     
    alb-lab likes this.
  4. alb-lab

    alb-lab

    Joined:
    Feb 2, 2019
    Posts:
    11
    Thank you very much for you reply !
    With this solution the situation improved.

    Now I can enter and exit the scene 2 (the one with the image marker) over and over without any fault. That's good.

    But if I enter the scene 3 (the one with face tracking) it only works for the first time. From the second time on, it starts to drift the location of my 3d objects. This problem affects also the objects of scene 2.

    It seems that the face tracking scene corrupts in some way all subsequent AR tracking and adds some sort of displacement to the position of the head or of the image marker.

    Any other idea to solve this ?
     
    Last edited: May 17, 2021
  5. alb-lab

    alb-lab

    Joined:
    Feb 2, 2019
    Posts:
    11
    Can't find a way to make this work. :(

    Any help will be very appreciated !
     
  6. jmunozarUTech

    jmunozarUTech

    Unity Technologies

    Joined:
    Jun 1, 2020
    Posts:
    295
    Hello @alb-lab we are looking into this.
     
  7. alb-lab

    alb-lab

    Joined:
    Feb 2, 2019
    Posts:
    11
    Thank you!
    From your reply I suppose you've been able to replicate the problem.

    My client wants the iOS version now... :( The app is very basic without any fancy feature other than different scenes.
     
  8. G_Abb

    G_Abb

    Joined:
    Aug 9, 2019
    Posts:
    2
    Hi everybody!

    I'm Gianluca, I'm working with Alberto on an augmented reality application developed with Mars.
    The work we are developing is an artistic application for a photography exhibition in Italy.
    The exhibition is open to the public and the application is already available on google store.
    It runs very well on android but the client is waiting for a Ios release
    Unfortunately as Alberto described with IOS "It seems that the face tracking scene corrupts in some way all subsequent AR tracking and adds some sort of displacement to the position of the head or of the image marker" so we are really stuck on this.
    In one way or another we need to solve this problem.

    On https://www.terraignota.site take a quick look at the project and the application we are working on.

    I was wondering is it possible to have support on these kinds of issues or maybe I should sign up for Unity Core Support?

    Mars is amazing and I hope to hear from you soon!
    Thanks guys in advance!
     
  9. jmunozarUTech

    jmunozarUTech

    Unity Technologies

    Joined:
    Jun 1, 2020
    Posts:
    295
    hello @G_Abb, @alb-lab,

    We have managed to reproduce this issue and we are working on a fix with urgency, will update when we either have a workaround or a fix for you guys
     
  10. alb-lab

    alb-lab

    Joined:
    Feb 2, 2019
    Posts:
    11
    Thank you so much @jmunozarUTech for taking care of this problem with urgency ! We really need a fix or a workaround.
     
  11. CiaranWills

    CiaranWills

    Unity Technologies

    Joined:
    Apr 24, 2020
    Posts:
    151
    In the face tracking scene can you try setting the Requested Max Face Count on the MARS Session to 1 and let me know if that improves things any?

    There seem to be a couple of intersecting bugs here that I am still getting to the bottom of…
     
    alb-lab and jmunozarUTech like this.
  12. alb-lab

    alb-lab

    Joined:
    Feb 2, 2019
    Posts:
    11
    Just tried changing that parameter from -1 to 1 and unfortunately there's no difference.
     
  13. CiaranWills

    CiaranWills

    Unity Technologies

    Joined:
    Apr 24, 2020
    Posts:
    151
    Also, if you aren't already, call AR Foundation's LoaderUtility Deinitialize() and Initialize() when switching scenes. I've seen issues when switching between the front and rear cameras if you don't do this.
     
    alb-lab likes this.
  14. alb-lab

    alb-lab

    Joined:
    Feb 2, 2019
    Posts:
    11
    I tried adding the calls to Initialize() and Deinitialize() and after a bit of trial and error everything works well now! :)

    It's still not clear to me if the problem was due to the change of scene or to the change of front/back camera.

    Anyway, thank you so much for your support !
     
    jmunozarUTech likes this.
  15. CiaranWills

    CiaranWills

    Unity Technologies

    Joined:
    Apr 24, 2020
    Posts:
    151
    Awesome - glad it's working or you!

    We'll have MARS handle this internally in a future version, but for now the workaround is to call it yourself when switching scenes.
     
    alb-lab likes this.
  16. G_Abb

    G_Abb

    Joined:
    Aug 9, 2019
    Posts:
    2
    Thank you so much guys!
    The application works very well now also on IOS! :)

    ▀█▀ █░█ ▄▀█ █▄░█ █▄▀
    ░█░ █▀█ █▀█ █░▀█ █░█

    █▄█ █▀█ █░█
    ░█░ █▄█ █▄█
     
    CiaranWills and thomas_key like this.