Vuforia not clearing up after using Unity additive loading

June 3, 2015 - 6:31am #1

Hi guys we are experiencing a crash bug with the following:

Unity: 4.6.5f1

Vuforia: v4.2.3

Xcode: 6.3.1

 

We are currently in the process of upgrading an old (32 bit) app to 64 bit compatible. The app is built using an inhouse framework that uses additive loading rather than Unity's standard scene system. We keep all scene objects inside a parent container and destroy the container to unload the scenes. The crash occurs the 2nd time you enter the AR area of the app. The crash does not occur in the editor.

The gameobject heirachys are correct when destroying the AR scene (there are no AR objects left). Using the standard loading scene method clears up Vuforia correctly although this is a huge change to the app structure.

Is there a way to force Vuforia to clear up?

 

To reproduce:

Create a simple project that has:

  • a base root scene
  • a 2nd scene container the AR camera and image targets (all withing a container object)
  • a 3rd scene that is blank (current has a simple UI to indicate the current scene showing)
  • A script to load and unload (by destroying the container objects) the scenes. 
  • A function to switch scenes

Set the backend to IL2CPP and Universal

Build to Xcode

Run on a 64 bit device.

 

Here is the crash log from Xcode.

System.InternalEnumerator`1:get_Current()

UnityEngine.Debug:Internal_Log(Int32, String, Object)

UnityEngine.Debug:Log(Object)

TestLoadingManager:SetNewContainer(GameObject)

LoadSceneOnTouch:Start()

System.InternalEnumerator`1:get_Current()

 

(Filename: /Users/builduser/buildslave/unity/build/artifacts/iPhonePlayer-armv7-il2cppGenerated/UnityEngineDebug.cpp Line: 56)

 

Trackable Shakespeare_Globe_Logo lost

System.InternalEnumerator`1:get_Current()

UnityEngine.Debug:Internal_Log(Int32, String, Object)

UnityEngine.Debug:Log(Object)

Vuforia.DefaultTrackableEventHandler:OnTrackingLost()

Vuforia.DefaultTrackableEventHandler:OnTrackableStateChanged(Status, Status)

TestLoadingManager:UnloadLevel()

Vuforia.TrackableBehaviour:RegisterTrackableEventHandler(ITrackableEventHandler)

Vuforia.DefaultTrackableEventHandler:Start()

System.InternalEnumerator`1:get_Current()

 

(Filename: /Users/builduser/buildslave/unity/build/artifacts/iPhonePlayer-armv7-il2cppGenerated/UnityEngineDebug.cpp Line: 56)

 

Trackable FirstFolio2 lost

System.InternalEnumerator`1:get_Current()

UnityEngine.Debug:Internal_Log(Int32, String, Object)

UnityEngine.Debug:Log(Object)

Vuforia.DefaultTrackableEventHandler:OnTrackingLost()

Vuforia.DefaultTrackableEventHandler:OnTrackableStateChanged(Status, Status)

TestLoadingManager:UnloadLevel()

Vuforia.TrackableBehaviour:RegisterTrackableEventHandler(ITrackableEventHandler)

Vuforia.DefaultTrackableEventHandler:Start()

System.InternalEnumerator`1:get_Current()

 

(Filename: /Users/builduser/buildslave/unity/build/artifacts/iPhonePlayer-armv7-il2cppGenerated/UnityEngineDebug.cpp Line: 56)

 

cameraDeviceGetVideoMode

Trackable Shakespeare_Globe_Logo lost

System.InternalEnumerator`1:get_Current()

UnityEngine.Debug:Internal_Log(Int32, String, Object)

UnityEngine.Debug:Log(Object)

Vuforia.DefaultTrackableEventHandler:OnTrackingLost()

Vuforia.DefaultTrackableEventHandler:OnTrackableStateChanged(Status, Status)

TestLoadingManager:UnloadLevel()

Vuforia.TrackableBehaviour:OnTrackerUpdate(Status)

Vuforia.DataSetTrackableBehaviour:OnTrackerUpdate(Status)

TestLoadingManager:UnloadLevel()

Vuforia.StateManagerImpl:UpdateTrackablePoses(Transform, TrackableResultData[], Int32, Int32)

Vuforia.QCARManagerImpl:UpdateTrackers(FrameState)

Vuforia.QCARManagerImpl:Update(ScreenOrientation)

Vuforia.QCARAbstractBehaviour:Update()

System.InternalEnumerator`1:get_Current()

 

(Filename: /Users/builduser/buildslave/unity/build/artifacts/iPhonePlayer-armv7-il2cppGenerated/UnityEngineDebug.cpp Line: 56)

 

Trackable FirstFolio2 lost

System.InternalEnumerator`1:get_Current()

UnityEngine.Debug:Internal_Log(Int32, String, Object)

UnityEngine.Debug:Log(Object)

Vuforia.DefaultTrackableEventHandler:OnTrackingLost()

Vuforia.DefaultTrackableEventHandler:OnTrackableStateChanged(Status, Status)

TestLoadingManager:UnloadLevel()

Vuforia.TrackableBehaviour:OnTrackerUpdate(Status)

Vuforia.DataSetTrackableBehaviour:OnTrackerUpdate(Status)

TestLoadingManager:UnloadLevel()

Vuforia.StateManagerImpl:UpdateTrackablePoses(Transform, TrackableResultData[], Int32, Int32)

Vuforia.QCARManagerImpl:UpdateTrackers(FrameState)

Vuforia.QCARManagerImpl:Update(ScreenOrientation)

Vuforia.QCARAbstractBehaviour:Update()

System.InternalEnumerator`1:get_Current()

 

(Filename: /Users/builduser/buildslave/unity/build/artifacts/iPhonePlayer-armv7-il2cppGenerated/UnityEngineDebug.cpp Line: 56)

 

cameraDeviceGetVideoMode

2015-06-03 12:37:51.124 vuforia4Test[896:257328] Uncaught exception: NSRangeException: *** -[__NSArrayM objectAtIndex:]: index 2305843009213689857 beyond bounds [0 .. 1]

(

0   CoreFoundation                      0x0000000183fc20a0 <redacted> + 160

1   libobjc.A.dylib                     0x00000001945a80e4 objc_exception_throw + 60

2   CoreFoundation                      0x0000000183ea7bec <redacted> + 0

3   vuforia4Test                        0x000000010110bcac _ZNK4QCAR5Box3D18getMaximumPositionEv + 1070660

4   vuforia4Test                        0x00000001010e0f08 _ZNK4QCAR5Box3D18getMaximumPositionEv + 895136

5   vuforia4Test                        0x00000001010c5618 _ZNK4QCAR5Box3D18getMaximumPositionEv + 782256

6   vuforia4Test                        0x00000001010c5748 _ZNK4QCAR5Box3D18getMaximumPositionEv + 782560

7   vuforia4Test                        0x00000001010a56e8 _ZNK4QCAR5Box3D18getMaximumPositionEv + 651392

8   vuforia4Test                        0x0000000101496ae0 _ZNK4QCAR5Box3D18getMaximumPositionEv + 4785272

9   vuforia4Test                        0x0000000101492b78 _ZNK4QCAR5Box3D18getMaximumPositionEv + 4769040

10  vuforia4Test                        0x000000010109ac5c _ZNK4QCAR5Box3D18getMaximumPositionEv + 607732

11  vuforia4Test                        0x000000010109adb0 _ZNK4QCAR5Box3D18getMaximumPositionEv + 608072

12  vuforia4Test                        0x0000000100fec07c _ZN4QCAR8Renderer11getInstanceEv + 860

13  vuforia4Test                        0x0000000100fec210 _ZN4QCAR8Renderer11getInstanceEv + 1264

14  vuforia4Test                        0x0000000100fdda70 UnityRenderEvent + 296

15  vuforia4Test                        0x0000000100aaac20 _Z19PluginsRenderMarkeri + 108

16  vuforia4Test                        0x00000001004acd20 GL_IssuePluginEvent_m5517 + 84

17  vuforia4Test                        0x00000001002c3558 QCARRendererImpl_UnityRenderEvent_m3924 + 52

18  vuforia4Test                        0x00000001002c33e0 QCARManagerImpl_StartRendering_m3898 + 516

19  vuforia4Test                        0x0000000100324cf8 VideoBackgroundAbstractBehaviour_RenderOnUpdate_m5110 + 280

20  vuforia4Test                        0x000000010032b5c0 Action_Invoke_m377 + 192

21  vuforia4Test                        0x0000000100135b7c _ZN18VirtActionInvoker06InvokeEP10MethodInfoPv + 72

22  vuforia4Test                        0x00000001003153f0 QCARAbstractBehaviour_Update_m5043 + 2912

23  vuforia4Test                        0x0000000100769440 _Z23RuntimeInvoker_Void_t49P10MethodInfoPvPS1_ + 60

24  vuforia4Test                        0x0000000100fc85b4 _ZN6il2cpp2vm7Runtime6InvokeEP10MethodInfoPvPS4_PP12Il2CppObject + 68

25  vuforia4Test                        0x0000000100af40f8 _ZN25ScriptingInvocationNoArgs6InvokeEPP18ScriptingException + 96

26  vuforia4Test                        0x0000000100af408c _ZN25ScriptingInvocationNoArgs6InvokeEv + 32

27  vuforia4Test                        0x0000000100aec358 _ZN13MonoBehaviour16CallUpdateMethodEi + 228

28  vuforia4Test                        0x0000000100a214c4 _ZN20BaseBehaviourManager12CommonUpdateI16BehaviourManagerEEvv + 92

29  vuforia4Test                        0x0000000100aa995c _Z10PlayerLoopbbP10IHookEvent + 1156

30  vuforia4Test                        0x000000010088aecc UnityPlayerLoop + 32

31  vuforia4Test                        0x000000010010683c _ZL16UnityRepaintImplb + 108

32  vuforia4Test                        0x000000010010604c UnityRepaint + 20

33  vuforia4Test                        0x000000010010602c -[UnityAppController(Rendering) repaint] + 92

34  vuforia4Test                        0x0000000100105f1c __51-[UnityAppController(Rendering) repaintDisplayLink]_block_invoke + 76

35  libdispatch.dylib                   0x0000000103c1cf20 _dispatch_call_block_and_release + 24

36  libdispatch.dylib                   0x0000000103c1cee0 _dispatch_client_callout + 16

37  libdispatch.dylib                   0x0000000103c2184c _dispatch_main_queue_callback_4CF + 1056

38  CoreFoundation                      0x0000000183f798dc <redacted> + 12

39  CoreFoundation                      0x0000000183f77984 <redacted> + 1492

40  CoreFoundation                      0x0000000183ea5664 CFRunLoopRunSpecific + 396

41  GraphicsServices                    0x000000018cfe75a4 GSEventRunModal + 168

42  UIKit                               0x00000001887aa984 UIApplicationMain + 1488

43  vuforia4Test                        0x00000001000ffd68 main + 248

44  libdyld.dylib                       0x0000000194c16a08 <redacted> + 4

)

2015-06-03 12:37:51.126 vuforia4Test[896:257328] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 2305843009213689857 beyond bounds [0 .. 1]'

*** First throw call stack:

(0x183fc2084 0x1945a80e4 0x183ea7bec 0x10110bcac 0x1010e0f08 0x1010c5618 0x1010c5748 0x1010a56e8 0x101496ae0 0x101492b78 0x10109ac5c 0x10109adb0 0x100fec07c 0x100fec210 0x100fdda70 0x100aaac20 0x1004acd20 0x1002c3558 0x1002c33e0 0x100324cf8 0x10032b5c0 0x100135b7c 0x1003153f0 0x100769440 0x100fc85b4 0x100af40f8 0x100af408c 0x100aec358 0x100a214c4 0x100aa995c 0x10088aecc 0x10010683c 0x10010604c 0x10010602c 0x100105f1c 0x103c1cf20 0x103c1cee0 0x103c2184c 0x183f798dc 0x183f77984 0x183ea5664 0x18cfe75a4 0x1887aa984 0x1000ffd68 0x194c16a08)

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

(lldb) 

Vuforia not clearing up after using Unity additive loading

June 5, 2015 - 7:05am #2

I managed to fix the problem myself but thought I would post just incase anyone else is having the same issue.

If you unload the scene (By destroying the scene container) and destroy the AR camera in the same frame it casues a null reference somewhere. This is most likely to do with script destruction order.

If you destroy the AR camera and related objects (Image targets) the frame after destroying the Scene container the crash no longer appears.

Log in or register to post comments