Topic locked

Application Crash on some Android Devices

July 3, 2014 - 1:23am #1
Hi,
 
I am experiencing crashes on some mobile devices for my app.
 
I looked in the forums for a similar issue being asked but could not find one, hence I am starting this new thread.
 
I was not sure whether I should post this thread in Unity Tech Discussion or Issues and Bugs. Anyway, since it is related to an application developed with Unity I thought it would be more appropriate to post here.
 
Kindly correct me if I am wrong.
 
Following are the details :
 
 
 
API Versions Used
 
(I am using all the latest versions.)
 
Unity Version: 4.5.1f3
 
Vuforia Version: Unity Extension 3.0.6 for Android & iOS
 
 
Other Pacakges used in Unity Project
 
 
 
Test Devices (All Android)
 
ASUS MeMo Pad HD7 ME173X
Android Version: 4.2.2
 
 
ASUS Nexus 7, 2nd generation
Chipset: Qualcomm Snapdragon S4 Pro APQ8064–1AA
Android Version: 4.4.3
 
Moto X
Model No: XT1058
Chipset: Qualcomm MSM8960Pro Snapdragon
Android Version: 4.4.2
 
 
 
Description of Crash
 
The first version of the application ran successfully on all the above mentioned devices. However, I found that the Camera Texture was defocussed sometimes. This lead to tracking issues. To resolve this, I added a script on the ARCamera Prefab in my scenes which sets the focus mode. The script is as follows:
 
using UnityEngine;
using System.Collections;

public class CameraAutoFocus : MonoBehaviour 
{

	void Start()
	{
		StartCoroutine(SetInitialFocus());
	}


	IEnumerator SetInitialFocus()
	{
		yield return new WaitForEndOfFrame();

		bool focusModeSet = CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);
		if (!focusModeSet) 
		{
			Debug.Log("Failed to set focus mode (unsupported mode).");
		} 

	}

	void OnEnable()
	{
		UIEventsManager.OnSetFocusEvent += HandleOnSetFocusEvent;
	}

	void Disable()
	{

		UIEventsManager.OnSetFocusEvent += HandleOnSetFocusEvent;
	}

	void HandleOnSetFocusEvent ()
	{
		TriggerFocus();
	}

	void TriggerFocus()
	{
		bool focusModeSet = CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_TRIGGERAUTO);
		
		if (!focusModeSet) 
		{
			Debug.Log("Failed to set focus mode (unsupported mode).");
		}

		else
		{
			Debug.Log("Successfully set focus mode to TriggetAuto.");

		}

	}

}

 

In the above code, UIEventsManager forwards an event at a button press which this script subscribes to. This lets the user to set focus manually at the press of button.

After adding this script, the app worked flawlessly with rock-solid tracking on ASUS MeMo Pad, but failed intermittently on Nexus and Moto. The application has three different AR related scenes. As soon as the scene loads, the crash happens, saying that  'Unfortunately <app> has crashed.'.  It sometimes worked on a few scenes but failed on others randomly. Also once it starts to crash on a device, any successive attempts to run the app increases the crashing.

 

 

 

I tried changing:

CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_CONTINUOUSAUTO);

to

CameraDevice.Instance.SetFocusMode(CameraDevice.FocusMode.FOCUS_MODE_NORMAL);

But the crash persisted on Nexus and Moto. Interestingly, all builds worked fine on ASUS MeMo Pad. I have not experienced a single crash on this device with any Focus Mode Setting so far.

 

My best guess is that there is a bug somewhere in communicating wtih or getting the Camera Device on some devices.

 

Kindly help.

 

Application Crash on some Android Devices

November 4, 2014 - 11:56pm #8

Great ;-)

Application Crash on some Android Devices

November 4, 2014 - 11:32pm #7

Yes Alessandro,  I have already built with unity 4.5.5. The App works fine with this latest version.

Application Crash on some Android Devices

November 3, 2014 - 8:15am #6

BTW: You may want to consider using the latest Unity 4.5.5

Application Crash on some Android Devices

November 2, 2014 - 8:49pm #5

hey, thanks for the reply! I will try to compile it on 4.5.4.

hope it fixes it :)

Application Crash on some Android Devices

November 2, 2014 - 8:47pm #4

Hello Alexv,

The rollback did indeed solve my problems at that point of time. But please note that later with an Upgrade of Unity as well as Vuforia, the problem was fixed. Now I have the same application running fine on all the devices without any crash with the latest version of Unity (4.5.4) and Vuforia (3.0.9).

Application Crash on some Android Devices

October 24, 2014 - 9:23pm #3

I think I have some random crashes that may be related to your problem, did a rollback fix the issue? did you get any findings from your tests?

thanks!

Application Crash on some Android Devices

July 4, 2014 - 3:33am #2

Just wanted to add  - In a previous version of my app, I was using Vuforia version 2.8.7. This version worked well on all Android Devices, although I was not playing with the Camera Focus mode. Could it be that the new version is causing crashes on Nexus?

 

I will be rolling back to 2.8.7 from 3.0.6 and see if I have any luck.

I will post my findings soon.

Topic locked