Topic locked

NSRangeException after reloading scene on iOS (Unity)

October 1, 2015 - 1:31am #1

Vuforia SDK Version: last -
Description with steps to reproduce:

When app runs on any iOS device, after some objrect recognition and switching off camera, after reloading scene with ARCamera app crashes with error:

 

*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 26282076 beyond bounds [0 .. 1]'

*** First throw call stack:

(0x21a10fef 0x2fc8fc8b 0x21923821 0x11678cf 0x1127d75 0x1106bd1 0x1106ccf 0x10e0bbd 0x1553a03 0x154f455 0x10d0841 0x10d0967 0x100d13f 0x100d33d 0x167dabf 0xa332a7 0x591b75 0x5bd68f 0x89ea1b 0xff756d 0xa7802d 0xa77fef 0xa71a15 0x9bfff5 0xa32895 0x8c79ab 0x7850d 0x78351 0x34b9173 0x34b915f 0x34bce45 0x219d6609 0x219d4d09 0x21921201 0x21921013 0x290ae201 0x250c5a59 0x7132b 0x3021baaf)

libc++abi.dylib: terminating with uncaught exception of type NSException

(lldb) 

I have tryed many things, like keep ARCamera alive (after that object recognition dont works), tryed stop () and deinit() before reloading scene, and no one thing helps.

 

Also I have another  bug, after object recognition but not switching off ARCamera (setActive(false)), when I reload scene, ARCamera dont works, but no crash heppens, app works.

 

2015-10-01 10:53:19.369 muByzantium[541:135994] Failed to set hint 'HINT_MAX_SIMULTANEOUS_IMAGE_TARGETS' because the ObjectTracker has not been initialized.

SetHint

(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)

2015-10-01 10:53:19.369 muByzantium[541:135994] Failed to set hint 'HINT_MAX_SIMULTANEOUS_OBJECT_TARGETS' because the ObjectTracker has not been initialized.

SetHint

(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)

2015-10-01 10:53:19.370 muByzantium[541:135994] Failed to set hint 'HINT_DELAYED_LOADING_OBJECT_DATASETS' because the ObjectTracker has not been initialized.

dataSetExists

objectTrackerCreateDataSet

Error: Object Tracker not ready. Could not create data set.

Could not create dataset.

Vuforia.VuforiaAbstractBehaviour:Start()

(Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)

NullReferenceException: A null value was found where an object instance was required.

  at Vuforia.DatabaseLoadAbstractBehaviour.LoadDatasets () [0x00000] in <filename unknown>:0 

  at Vuforia.VuforiaAbstractBehaviour.Start () [0x00000] in <filename unknown>:0 

(Filename: currently not available on il2cpp Line: -1)

cameraDeviceGetVideoMode

2015-10-01 10:53:19.372 muByzantium[541:135994] VideoBackgroundConfig with screen size of zero received, skipping config step

2015-10-01 10:53:19.373 muByzantium[541:135994] CameraDevice::getCameraCalibration(): Failed to get camera calibration because the camera is not initialized.

 

 

I think I need somehow fully unload Vuforia from memory and then load again. How can I do that?

-
Development OS (Mac OS X, Windows, Linux): Mac OS X -
Mobile OS and Version: any iOS -
Mobile Device Manufacturer and Model name: apples -
Do the Vuforia Sample Applications show the same behavior?: dont know

NSRangeException after reloading scene on iOS (Unity)

October 8, 2015 - 4:16am #6

you're welcome ;-)

NSRangeException after reloading scene on iOS (Unity)

October 8, 2015 - 4:02am #5

Thanks Hackerman Alessandro!!!! I killed a week on this bug and now all works!

NSRangeException after reloading scene on iOS (Unity)

October 8, 2015 - 1:34am #4

When loading a new scene, the content (game objects) of the previous scene should be automatically "unloaded" (and destroyed) by Unity;

 

this is the default behaviour of Unity, unless you explicitely call the DontDestroyOnLoad API, see:

http://docs.unity3d.com/ScriptReference/Object.DontDestroyOnLoad.html

("When loading a new level all objects in the scene are destroyed, then the objects in the new level are loaded")

 

Vuforia also adds a further abstraction of its object life-cycle through the "Keep Alive" option, which you can enable in the ARCamera inspector to prevent the ARCamera (and optionally other Vuforia objects as well) to be preserved (not destroyed) when loading a new scene;   so you may want to check that you are NOT using the "Keep Alive" behaviour.

 

Also, from your first post, I noticed this statement:

"...after some objrect recognition and switching off camera, after reloading scene with ARCamera app crashes ..."

It sounds like you are explicitly turning off the ARCamera (if I read and understand correctly) just before loading a new scene; but as explained before, this is not needed, and it is also not recommended to disable the ARCamera game object; this might actually be the reason for your crash.

Could you try just loading a new scene without disabling the ARCamera and see if the crash disappear ? or is there another specific reason why you need to enforce the ARCamera disabling before switching scene ?

 

 

 

 

NSRangeException after reloading scene on iOS (Unity)

October 8, 2015 - 1:09am #3

Thanks for answer, but how can I fully switch off Vuforia? (unload from memory)

NSRangeException after reloading scene on iOS (Unity)

October 7, 2015 - 10:17pm #2

Delfuego wrote:

I think I need somehow fully unload Vuforia from memory and then load again. How can I do that?

  1. Import ImageTargets 5.0.5 into new project
  2. Add 1 or 2 non-Vuforia scenes to project
  3. Add UI buttons to all 3 scenes to nav between them
  4. If successful, add object reco model to dataset next

 

Topic locked