AR Image Tracking not working in iOS but working fine in Android

Hi, I have developed an AR app which tracks multiple images and renders AR models onto it. It contains 20 image targets with 20 models, So first I built it for Android and published on the play store, everything worked fine. But as soon as I built it for iOS, firstly for 20 images, camera din’t open and the app crashed, so I thought it must be memory issue, therefore for the trail purpose I only kept 3 images and their corresponding models should come up.

When run on iPhone or iPad, it constantly shows “Tracking Lost” text and doesn’t render the model.
When run on Android for how much ever images, works completely fine.

For AR image tracking I am using this script :-

```csharp
*using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;
using TMPro;

public class MultiTargetManager : MonoBehaviour
{
[SerializeField] private ARTrackedImageManager aRTrackedImageManager;
[SerializeField] private GameObject aRModelsToPlace;
//[SerializeField] private GameObject ArMain;
[SerializeField] private GameObject trackingLostPopup; // Popup to show when tracking is lost

private Dictionary<string, GameObject> aRModels = new Dictionary<string, GameObject>();
private Dictionary<string, bool> modelState = new Dictionary<string, bool>();
// Start is called before the first frame update
void Start()
{
foreach (var aRModel in aRModelsToPlace)
{
GameObject newARModel = Instantiate(aRModel, Vector3.zero, Quaternion.identity);
newARModel.name = aRModel.name;
aRModels.Add(newARModel.name, newARModel);
newARModel.SetActive(false);
modelState.Add(newARModel.name, false);
}
}

private void OnEnable()
{
aRTrackedImageManager.trackedImagesChanged += ImageFound;
}

private void OnDisable()
{
aRTrackedImageManager.trackedImagesChanged -= ImageFound;
}

private void ImageFound(ARTrackedImagesChangedEventArgs eventData)
{
foreach (var trackedImage in eventData.added)
{
ShowARModel(trackedImage);
}
foreach (var trackedImage in eventData.updated)
{
if (trackedImage.trackingState == TrackingState.Tracking)
{
ShowARModel(trackedImage);
trackingLostPopup.GetComponent().text = “Tracking Active”;
}
else if(trackedImage.trackingState == TrackingState.Limited)
{
HideARModel(trackedImage);
trackingLostPopup.GetComponent().text = “Tracking Lost”;
}
}
}

private void ShowARModel(ARTrackedImage trackedImage)
{
bool isModelActivated = modelState[trackedImage.referenceImage.name];
if (!isModelActivated)
{

GameObject aRModel = aRModels[trackedImage.referenceImage.name];
aRModel.transform.position = trackedImage.transform.position;
aRModel.transform.rotation = trackedImage.transform.rotation;
aRModel.SetActive(true);
modelState[trackedImage.referenceImage.name] = true;
}
else
{
GameObject aRModel = aRModels[trackedImage.referenceImage.name];
aRModel.transform.position = trackedImage.transform.position;
aRModel.transform.rotation = trackedImage.transform.rotation;
}
}

private void HideARModel(ARTrackedImage trackedImage)
{
bool isModelActivated = modelState[trackedImage.referenceImage.name];
if (isModelActivated)
{
GameObject aRModel = aRModels[trackedImage.referenceImage.name];
aRModel.SetActive(false);
modelState[trackedImage.referenceImage.name] = false;
}
}
}*
```

Versions i am using :-
Unity - 2021.3.28f1
AR Foundation - 4.2.10
AR Kit - 4.2.10
AR Core - 4.2.10
XR Plugin Management - 4.3.3

I tried the project in Unity 2021.3.15f1
AR Kit - 4.2.9

Still doesn’t work.

Here is the image of my Player Settings.

Please help me resolve this issue.

Also, I wanted to downgrade the AR Kit versions, but dint find a way to do so.

Thanks in Advance

Do you experience the same issue on ARKit with our sample app?

The image tracking with multiple prefabs scene demonstrates the same use case that you have here. You can use our code as reference.

I’m not quite having the same issue but something you mentioned happened to me as well. I developed an app that tracks 2D images and displays a video on top of them using a Quad with a video player in a prefab to display it.

The issue is that I build it for Android and everything came out well same as you did, but when I build for IOS and scan the image that is in the reference library the prefab appears (and I can notice because I have a UI element on it) but the actual Quad with the video player that is supposed to be on top of the image is nowhere to be found.
Through several testing I noticed that the Quad does appear but it is very off when it comes to the place where it supposed to be which is on top of the image. I tried to change position, play with the scale, size but nothing the Quad still appears very far away, too close to see it or tillted in a strange way. I’m not able to find the sweet spot like on Android that it just appears on top of the scanned image.

Hello,

If either @aneri1997 or @claudioocs7 could confirm whether or not they get this behavior within the sample app – the link provided by @andyb-unity above, they will help us narrow down whether the issue lies within the AR Foundation package, or relates to some detail that is specific to your code.

I am having this issue on the sample project you provided, it works fine on android but not on IOS. On IOS it didn’t track anything but ask for camera permission. I am not sure if it tracks the image but the 3d model I want to instantiate on top of it didn’t appear

I can confirm that on IOS is not working good the TrackingState, it’s always limited.

What iOS device(s) have you used to reproduce this issue? Note that we are aware of an issue reported to Apple regarding the iPhone 15 Pro Max that sounds like it could be related: Different ARFoundation Behavior between iPhone 12 pro and iPhone 15 pro max

@simarlab I just reproduced your report of “tracking state always Limited” on my iPhone 13 Pro. After an initial review of our plug-in code, this looks to be an Apple issue. Our plug-in simply reports the data that we receive from Apple.

Out of curiosity, did you test with a digital image on a screen, or a printout of the image? My test was digital, and I suspect that iOS would perform better with a higher pixel-density printout.

Hi, the tracking state remains limited after tracking the image, this occurs in the sample project also. I have tested with the digital images given in the sample project, even though, the result remains same.
Is there any solution?

I tried with the sample scene “Basic Image Tracking”.
Unity version : Unity 6 (6000.0.23fl)
AR Foundation : v6.0.3
Tested with iPhone 12

in this script, else statement never hits, when I am not scanning the image.

// script from sample project

void UpdateInfo(ARTrackedImage trackedImage)
        {
            // Set canvas camera
            var canvas = trackedImage.GetComponentInChildren<Canvas>();
            canvas.worldCamera = worldSpaceCanvasCamera;

            // Update information about the tracked image
            var text = canvas.GetComponentInChildren<Text>();
            text.text = string.Format(
                "{0}\ntrackingState: {1}\nGUID: {2}\nReference size: {3} cm\nDetected size: {4} cm",
                trackedImage.referenceImage.name,
                trackedImage.trackingState,
                trackedImage.referenceImage.guid,
                trackedImage.referenceImage.size * 100f,
                trackedImage.size * 100f);

            var planeParentGo = trackedImage.transform.GetChild(0).gameObject;
            var planeGo = planeParentGo.transform.GetChild(0).gameObject;

            // Disable the visual plane if it is not being tracked
            if (trackedImage.trackingState != TrackingState.None)   
            {
                planeGo.SetActive(true);

                // The image extents is only valid when the image is being tracked
                trackedImage.transform.localScale = new Vector3(trackedImage.size.x, 1f, trackedImage.size.y);

                // Set the texture
                var material = planeGo.GetComponentInChildren<MeshRenderer>().material;
                material.mainTexture = (trackedImage.referenceImage.texture == null) ? defaultTexture : trackedImage.referenceImage.texture;
            }
            else
            {
                planeGo.SetActive(false);
            }
        }

As I mentioned in previous reply to this thread, this appears to be a regression on Apple’s side. Please file a support ticket with Apple for this issue. We are correctly reporting the data that we receive from them.