Topic locked

EXC_BAD_ACCESS error Unity 4.5.4 / Vuforia v3.0.9

September 25, 2014 - 1:37am #1

Hello,

I'm experiencing an error building my iOS app on XCode6 on iOS8.

I'm using Unity v4.5.4 and Vuforia v3.0.9.

I have a EXC_BADD_ACCESS error on this line :

QCARUnityPlayer::getInstance().QCARInit([orientation UTF8String]);

It is in the applicationDidBecomeActive method.

Do you know where does it come from ?

EXC_BAD_ACCESS error Unity 4.5.4 / Vuforia v3.0.9

January 23, 2015 - 10:38am #19

EXC_BAD_ACCESS error Unity 4.5.4 / Vuforia v3.0.9

November 18, 2014 - 10:11am #18

Thanks Jarzac for sharing your solution.

EXC_BAD_ACCESS error Unity 4.5.4 / Vuforia v3.0.9

November 18, 2014 - 4:18am #17

Hello,

 

I solved this by keeping alive the MKMapView. So whenever I need to display a Map on top of my AR component, I reuse the same MKMapView.

It seems that when the MKMapView gets destroyed, it takes its context with it, highly confusing Unity in the process.

So if you can afford it (memory and CPU wise) : keep your map alive (in a variable or anything). You don't even need to pause Unity or to set the current context to nil :)

 

Hope it helps

EXC_BAD_ACCESS error Unity 4.5.4 / Vuforia v3.0.9

October 20, 2014 - 12:14am #16

Hi ferhat,

 

you link does not allow to fix the issue we are discussing : here it is a EXC_BAD_ACCESS exception in the EAGLContextSetCurrentAutoRestore method on line [EAGLContext setCurrentContext: old].

 

As explained by fuertejake, this is a concurrency issue that occurs while Unity is paused and MKMapView is active. 

After having applied the fix described by fuertejake (i.e. do not repaint when Unity is paused, and set a nil context just before unpausing Unity), indeed I do not have EXC_BAD_ACCESS anymore, but on the other hand my AR View is only displayed once every 2 runs (othertwise I get a black screen). I think that this is a repaint call which is skipped due to this fix, but was not able to determine it through debug.

 

Fueterjake, could you give us more details about your fix ? Maybe I did something wrong with mine.

 

Regards,

Alex

EXC_BAD_ACCESS error Unity 4.5.4 / Vuforia v3.0.9

October 18, 2014 - 2:25am #15

EXC_BAD_ACCESS error Unity 4.5.4 / Vuforia v3.0.9

October 17, 2014 - 9:34am #14

I have the same problem but provided link does not work anymore.

EXC_BAD_ACCESS error Unity 4.5.4 / Vuforia v3.0.9

October 16, 2014 - 12:28am #13

Apparently, fuertejake solve the problem.

Here is the message he sent me :

Our problem was having Unity AND MKMapView running at the same time.
Unity/Vuforia holds on to a context that MKMapView's OpenGL also holds onto,
so that one of them would release their context while the other one was still
holding onto it hence all the context crashes in EAGLContext,

We have found that calling [EAGLContext setCurrentContext:nil]; before we
unpause unity fixes our issue. We also force Unity to stop repainting while
we have Unity paused.

It has fixed our issues... for now!

I haven't tried yet but it seems to fix the error :)

EXC_BAD_ACCESS error Unity 4.5.4 / Vuforia v3.0.9

October 3, 2014 - 4:26am #12

OK, could you make a quick test with one of the Vuforia samples and see if you get the same (or similar) error message ?  

EXC_BAD_ACCESS error Unity 4.5.4 / Vuforia v3.0.9

October 1, 2014 - 11:26pm #11

It's a custom App, but the error seems located in the Unity-generated code.

EXC_BAD_ACCESS error Unity 4.5.4 / Vuforia v3.0.9

October 1, 2014 - 12:28pm #10

Vuforia Sample or custom App ? 

EXC_BAD_ACCESS error Unity 4.5.4 / Vuforia v3.0.9

October 1, 2014 - 8:04am #9

Which part has solved your problem ? 

 

I encounter the exact same issue : I have an EXC_BAD_ACCESS exception in the EAGLContextSetCurrentAutoRestore method on line [EAGLContext setCurrentContext: old]

 

I've tried these two work-arounds (described in https://developer.vuforia.com/forum...-error-unity-454-vuforia-v309#comment-2044130)
https://developer.vuforia.com/forum/ios/ios-8-xcode-6-and-vuforia-30-compatibility to make sure that camera is correctly started
https://developer.vuforia.com/forum/unity-3-extension-technical-discussion/unity-454-and-vuforia-ios and forcing the orientation (both entries) to "UIInterfaceOrientationPortrait"

But none allows me to fix this issue, the memory pointed by "old" has been disposed.

EXC_BAD_ACCESS error Unity 4.5.4 / Vuforia v3.0.9

September 26, 2014 - 1:32am #8

Ok, indeed, we never observed thta specific crash your reported (in EAGLContextSetCurrentAutoRestore::~EAGLContextSetCurrentAutoRe......) in the Vuforia sample projects;

it seems this is probably related to the implementation of your custom iOS subview that you've added;  it would be great if you could debug this in Xcode and isolate the actual root-cause of the issue and assess whether this is just an application logic problem (i.e. your code not working on iOS8),

or if it is an issue that might be caused by Vuforia

 

 

EXC_BAD_ACCESS error Unity 4.5.4 / Vuforia v3.0.9

September 26, 2014 - 1:12am #7

It is on a custom project.

To explain, I use the Unity build as a subview from a AugmentedReality view controller.

But my problem come when I load two times a mapView.

It's a really strange problem but it appears only on iOS8. This app is working great on iOS7.

EXC_BAD_ACCESS error Unity 4.5.4 / Vuforia v3.0.9

September 26, 2014 - 1:02am #6

In your previous message you mentioned that this guide was resolving:

https://developer.vuforia.com/forum/unity-3-extension-technical-discussion/unity-454-and-vuforia-ios

But now you have an additional crash in that code; is that on a custom project ? or the samples ?

 

EXC_BAD_ACCESS error Unity 4.5.4 / Vuforia v3.0.9

September 26, 2014 - 12:33am #5

Thanks for this tutorial.

But I have a problem using Unity 4.5.4 in XCode6.
XCode send a EXC_BAD_ACCESS on the line

EAGLContextSetCurrentAutoRestore::~EAGLContextSetCurrentAutoRestore()
{
    if (old != cur)
        [EAGLContext setCurrentContext:old];
}

Of the EAGLContextHelper class.

 

I don't know why it is bugging on this line...

EXC_BAD_ACCESS error Unity 4.5.4 / Vuforia v3.0.9

September 25, 2014 - 11:12pm #4

In addition, since you are also using Xcode 6 and iOS8 (beside Unity 4.5.4),

You may also want to have a look at the complete migration guide for Xcode 6, Vuforia and iOS8, here:

https://developer.vuforia.com/forum/ios/ios-8-xcode-6-and-vuforia-30-compatibility

 

EXC_BAD_ACCESS error Unity 4.5.4 / Vuforia v3.0.9

September 25, 2014 - 3:54am #3

Thanks a lot this solve my problem :)

EXC_BAD_ACCESS error Unity 4.5.4 / Vuforia v3.0.9

September 25, 2014 - 2:31am #2
Topic locked