Topic locked

After updating sdk to vuforia-unity-android-ios-3-0-9 from 2-8-9 Unable to load dataset

January 5, 2015 - 11:51pm #1

Hi

I was using Untiy 4.2.1 and vuforia-unity-android-ios version 2-8-9 earlier for Android  and it was working fine. Now I have updated unity to 4.6.1 and vuforia sdk to 3.0.9 and now dataset is not getting loaded.

I have followed the instruction https://developer.vuforia.com/resources/dev-guide/extending-unity-android-activity-and-adding-custom-views-eclipse to integrate Unity with Eclipse and installed on device. I have also went through https://developer.vuforia.com/forum/unity-3-extension-technical-discussion/unity-46-and-vuforia-0.

 

I am attching my DataSetLoadBehaviour class Awake function where errror located...

void Awake()
    {
        if (!QCARRuntimeUtilities.IsQCAREnabled())
        {
            return;
        }

        if (QCARRuntimeUtilities.IsPlayMode())
        {
            // initialize QCAR 
            QCARUnity.CheckInitializationError();
        }

		if (TrackerManager.Instance.GetTracker<ImageTracker>() == null)
        {
			TrackerManager.Instance.InitTracker<ImageTracker>();
        }

        if (mDataSetsToLoad.Count <= 0)
        {
            Debug.LogWarning("No data sets defined. Not loading any data sets.");
            return;
        }
		
		print ("@@ DataSetLoadBehaviour::Awake():mDataSetsToLoad.Count="+mDataSetsToLoad.Count);
		
        foreach (string dataSetName in mDataSetsToLoad)
        {
			print ("@@ DataSetLoadBehaviour::Awake():dataSetName="+dataSetName);

            if (!DataSet.Exists(dataSetName))
            {
                Debug.LogError("Data set " + dataSetName + " does not exist.");
                continue;
            }

			ImageTracker imageTracker = (ImageTracker) TrackerManager.Instance.GetTracker<ImageTracker>();
			print ("@@ DataSetLoadBehaviour::Awake():imageTracker="+imageTracker);
			DataSet dataSet = imageTracker.CreateDataSet();
			print ("@@ DataSetLoadBehaviour::Awake():dataSet="+dataSet);

            if (!dataSet.Load(dataSetName))	//Unity4.6 + VuforiaSDk3.0.9. Seems like NullReferenceException error occuring here...
            {
                Debug.LogError("Failed to load data set " + dataSetName + ".");
                continue;
            }

			print ("@@ DataSetLoadBehaviour::Awake():mDataSetsToActivate.Contains(dataSetName)="+mDataSetsToActivate.Contains(dataSetName));
			// Activate the data set if it is the one specified in the editor.
            if (mDataSetsToActivate.Contains(dataSetName))
            {
                imageTracker.ActivateDataSet(dataSet);
				
				
				// OneUpload
				AttachContentToTrackables(dataSet);
            }
			
        }
    }

 

And here is log

01-06 10:44:12.524: I/Unity(15329): @@ DataSetLoadBehaviour::Awake():mDataSetsToLoad.Count=1

01-06 10:44:12.524: I/Unity(15329):  

01-06 10:44:12.524: I/Unity(15329): (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 49)

01-06 10:44:12.524: I/Unity(15329): @@ DataSetLoadBehaviour::Awake():dataSetName=20_External_9_May_2014

01-06 10:44:12.524: I/Unity(15329):  

01-06 10:44:12.524: I/Unity(15329): (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 49)

01-06 10:44:12.529: D/dalvikvm(15329): Trying to load lib /data/data/com.mobiware.xr/lib/libQCARWrapper.so 0x42c6e858

01-06 10:44:12.529: D/dalvikvm(15329): Shared lib '/data/data/com.mobiware.xr/lib/libQCARWrapper.so' already loaded in same CL 0x42c6e858

01-06 10:44:12.529: D/QCAR(15329): dataSetExists

01-06 10:44:12.954: I/Unity(15329): @@ DataSetLoadBehaviour::Awake():DataSet.Exists(dataSetName)=True

01-06 10:44:12.954: I/Unity(15329):  

01-06 10:44:12.954: I/Unity(15329): (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 49)

01-06 10:44:12.954: D/QCAR(15329): dataSetExists

01-06 10:44:13.374: I/Unity(15329): @@ DataSetLoadBehaviour::Awake():imageTracker=ImageTrackerImpl

01-06 10:44:13.374: I/Unity(15329):  

01-06 10:44:13.374: I/Unity(15329): (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 49)

01-06 10:44:13.374: D/dalvikvm(15329): Trying to load lib /data/data/com.mobiware.xr/lib/libQCARWrapper.so 0x42c6e858

01-06 10:44:13.374: D/dalvikvm(15329): Shared lib '/data/data/com.mobiware.xr/lib/libQCARWrapper.so' already loaded in same CL 0x42c6e858

01-06 10:44:13.379: D/QCAR(15329): imageTrackerCreateDataSet

01-06 10:44:13.379: I/AR(15329): ImageTracker: Successfully created dataset

01-06 10:44:13.379: D/QCAR(15329): Successfully created data set.

01-06 10:44:13.394: I/Unity(15329): @@ DataSetLoadBehaviour::Awake():dataSet=DataSetImpl

01-06 10:44:13.394: I/Unity(15329):  

01-06 10:44:13.394: I/Unity(15329): (Filename: ./artifacts/AndroidManagedGenerated/UnityEngineDebug.cpp Line: 49)

01-06 10:44:13.394: D/dalvikvm(15329): Trying to load lib /data/data/com.mobiware.xr/lib/libQCARWrapper.so 0x42c6e858

01-06 10:44:13.394: D/dalvikvm(15329): Shared lib '/data/data/com.mobiware.xr/lib/libQCARWrapper.so' already loaded in same CL 0x42c6e858

01-06 10:44:13.399: D/QCAR(15329): dataSetLoad

01-06 10:44:13.414: D/dalvikvm(15329): GC_FOR_ALLOC freed 21K, 7% free 12376K/13191K, paused 13ms, total 14ms

01-06 10:44:13.414: I/dalvikvm-heap(15329): Grow heap (frag case) to 15.065MB for 2499871-byte allocation

01-06 10:44:13.449: D/dalvikvm(15329): GC_CONCURRENT freed <1K, 6% free 14817K/15687K, paused 13ms+2ms, total 31ms

01-06 10:44:13.519: D/dalvikvm(15329): GC_FOR_ALLOC freed 2441K, 22% free 12377K/15687K, paused 12ms, total 12ms

01-06 10:44:13.519: I/dalvikvm-heap(15329): Grow heap (frag case) to 15.066MB for 2499615-byte allocation

.

.

.

.

.

01-06 10:44:15.699: D/dalvikvm(15329): Trying to load lib /data/data/com.mobiware.xr/lib/libQCARWrapper.so 0x42c6e858

01-06 10:44:15.699: D/dalvikvm(15329): Shared lib '/data/data/com.mobiware.xr/lib/libQCARWrapper.so' already loaded in same CL 0x42c6e858

01-06 10:44:15.699: D/QCAR(15329): imageTargetGetSize

01-06 10:44:15.709: D/dalvikvm(15329): Trying to load lib /data/data/com.mobiware.xr/lib/libQCARWrapper.so 0x42c6e858

01-06 10:44:15.709: D/dalvikvm(15329): Shared lib '/data/data/com.mobiware.xr/lib/libQCARWrapper.so' already loaded in same CL 0x42c6e858

01-06 10:44:15.709: D/QCAR(15329): imageTargetGetNumVirtualButtons

01-06 10:44:15.714: D/QCAR(15329): dataSetGetTrackableName

01-06 10:44:15.714: D/QCAR(15329): imageTargetGetSize

01-06 10:44:15.714: D/QCAR(15329): imageTargetGetNumVirtualButtons

01-06 10:44:15.714: D/QCAR(15329): dataSetGetTrackableName

.

.

.

12-29 15:21:03.553: I/Unity(3117): NullReferenceException: Object reference not set to an instance of an object

01-06 10:44:15.944: I/Unity(15329):   at StateManagerImpl.CreateImageTargetBehaviour (ImageTarget imageTarget) [0x00000] in <filename unknown>:0 

01-06 10:44:15.944: I/Unity(15329):   at StateManagerImpl.CreateMissingDataSetTrackableBehaviours (.DataSet dataSet) [0x00000] in <filename unknown>:0 

01-06 10:44:15.944: I/Unity(15329):   at StateManagerImpl.AssociateTrackableBehavioursForDataSet (.DataSet dataSet) [0x00000] in <filename unknown>:0 

01-06 10:44:15.944: I/Unity(15329):   at DataSetImpl.Load (System.String path, StorageType storageType) [0x00000] in <filename unknown>:0 

01-06 10:44:15.944: I/Unity(15329):   at DataSetImpl.Load (System.String name) [0x00000] in <filename unknown>:0 

01-06 10:44:15.944: I/Unity(15329):   at DataSetLoadBehaviour.Awake () [0x00000] in <filename unknown>:0 

01-06 10:44:15.944: I/Unity(15329):  

01-06 10:44:15.944: I/Unity(15329): (Filename:  Line: -1)

01-06 10:44:15.974: I/Unity(15329): Can't add component because class 'PremiumObjectFactoryStarterBehaviour' doesn't exist!

01-06 10:44:15.974: I/Unity(15329):  

01-06 10:44:15.974: I/Unity(15329): (Filename:  Line: 38)

01-06 10:44:15.974: I/Unity(15329): Can't add component because class 'PremiumComponentFactoryStarterBehaviour' doesn't exist!

01-06 10:44:15.974: I/Unity(15329):  

01-06 10:44:15.974: I/Unity(15329): (Filename:  Line: 38)

01-06 10:44:16.024: D/STATUSBAR-NetworkController(2604): refreshSignalCluster: data=-1 bt=false

01-06 10:44:16.024: D/STATUSBAR-SignalClusterView(2604): mSeparateMobileGroup=8

01-06 10:44:16.024: D/STATUSBAR-SignalClusterView(2604): mSeparateMobileGroup=8

01-06 10:44:16.024: D/STATUSBAR-SignalClusterView(2604): mSeparateMobileGroup=8

01-06 10:44:16.029: D/dalvikvm(15329): GC_CONCURRENT freed 426K, 25% free 12403K/16391K, paused 2ms+2ms, total 16ms

 

It seems like error is because of this line

Error: 12-29 15:21:03.553: I/Unity(3117): NullReferenceException: Object reference not set to an instance of an object

Line: if (!dataSet.Load(dataSetName))

 

But before this line I am printing datset instance value and it is...

01-06 10:44:13.394: I/Unity(15329): @@ DataSetLoadBehaviour::Awake():dataSet=DataSetImpl

 

Do I missed something important causing this problem?

 

Thanks in advance

 

 

After updating sdk to vuforia-unity-android-ios-3-0-9 from 2-8-9

January 7, 2015 - 11:51pm #4

Great ;-)

After updating sdk to vuforia-unity-android-ios-3-0-9 from 2-8-9

January 7, 2015 - 11:49pm #3

It's working... (y)

Thanks AlessandroB :-)

After updating sdk to vuforia-unity-android-ios-3-0-9 from 2-8-9

January 7, 2015 - 3:52am #2

You have put the loading code in the Awake, but this is not a best pratice;

a better way with 3.0.9 would be to:

- have your C# Class implement the interface ITrackerEventHandler 

- register your class instance with QCARBehaviour as Tracker Event Handler, in the Start() method of your class, i.e.:

void Start()  { 
  QCARBehaviour qcar = (QCARBehaviour)FindObjectOfType( typeof (QCARBehaviour) );
  qcar.RegisterTrackerEventHandler( this ); 
  ...

- implement the interface methods "public void OnInitialized()" and "public void OnTrackablesUpdated()"

- move all your Dataset Loading code from the Awake() method  to the OnInitialized() method (which ensures that QCAR and the Trackers have been initialized correctly);

 

Topic locked