Start a new topic

Crash calling InstantTracker.RequestPointCloud() in Unity/Android

Hi,


I modified Unity samples to fetch point cloud periodically (~2 times a second).

Doing so I experience app crash when running on Android (Debug build).


Here is my test code:

    protected override void Update()
    {
        base.Update();
        this.Label.text = string.Format("{0}", pointsCount);

        if (this._currentState == InstantTrackingState.Tracking && !waiting && delta > 0.5f)
        {
            try
            {
                this.waiting = true;
                Tracker.RequestPointCloud();
            }
            catch (Exception e)
            {
                this.Label.text = "failed";
                this.waiting = false;
            }
        }
        else
        {
            delta += Time.deltaTime;
        }
    }

    float delta = 0.0f;
    bool waiting = false;
    private int pointsCount;
    private void OnPointCloudRequestFinished(Vector3[] arg0)
    {
        pointsCount= arg0.Length;
        waiting = false;
        delta = 0.0f;
    }

Am I doing something wrong? For some reason I cannot get the Unity Debugger to connect with my smartphone so I cannot provide you with call stack details.


Has anyone reported similar issue before?


Thanks,

Luk


Hi,


Running your code worked fine for me. I only added the listener to the tracker in the Start method: 

protected override void Start() {
	base.Start();
	QualitySettings.shadowDistance = 4.0f;
	Tracker.OnPointCloudRequestFinished.AddListener(OnPointCloudRequestFinished);
}

 I also changed the code to print the pointsCount to the console:

 

protected override void Update()
{
	base.Update();

	if (this._currentState == InstantTrackingState.Tracking && !waiting && delta > 0.5f)
	{
		try
		{
			this.waiting = true;
			Tracker.RequestPointCloud();
		}
		catch (Exception e)
		{
			Debug.Log("Error requesting point cloud: " + e.Message);
			this.waiting = false;
		}
	}
	else
	{
		delta += Time.deltaTime;
	}
}

float delta = 0.0f;
bool waiting = false;
private int pointsCount;
private void OnPointCloudRequestFinished(Vector3[] arg0)
{
	pointsCount= arg0.Length;
	Debug.Log("pointsCount: " + pointsCount);
	waiting = false;
	delta = 0.0f;
}


Even if you cannot connect the debugger, you should still see error messages in Android Studio. It if is a Unity issue, there might also be some errors when running in the editor, even if tracking doesn't work.


Best regards,

Alexandru.

I did more testing yesterday and it crashed couple of times even without requesting the point cloud. I suspect Unity to be the root cause for that. I'll investigate a bit more with newer versions of Unity in coming days.


BTW Have you guys measure what is the overhead when using Unity vs native rendering with Wikitude?

Hi, 


Performance overhead should be minimal when using Unity in most cases.

On some older devices there might be some performance degradation when running FullHD cameras because we first need to render the camera to an offscreen buffer and which then Unity renders to the screen. In these cases we suggest using an SD frame.


Best regards,

Alexandru

Login or Signup to post a comment