f111fei / react-native-unity-view

Show an unity view in react native
MIT License
401 stars 102 forks source link

Thread 1: EXC_BAD_ACCESS (code=1, address=0x88) #98

Closed alisherakb closed 5 years ago

alisherakb commented 5 years ago

App is crashing after on launching

Screenshot 2019-03-15 at 11 40 33 AM

What can cause the issue?

Unity: 2018.2.17 "react-native": 0.58.6

alisherakb commented 5 years ago

@JanOwiesniak Have you ever experienced that behavior?

JanOwiesniak commented 5 years ago

Yes i ran into this issue several times.

It can be caused by a lot of stuff, sadly there is no general solution to this issue.

In summary, when you run into EXC_BAD_ACCESS, it means that you try to send a message to a block of memory that can't execute that message.

In some cases, however, EXC_BAD_ACCESS is caused by a corrupt pointer. Whenever your application attempts to dereference a corrupt pointer, an exception is thrown by the kernel.

In my particular case (i think) i lost a pointer to a 3rd party library (Vuforia) which resulted in this crash:

Vuforia::init()
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000992616966020

This workflow helped me fix this issue. I think step 8. (keeping a reference to the unity module was the game changer)


Another time i had issues with combination of react-navigation and UnityModule.createUnity. You can read more here.

alisherakb commented 5 years ago

Yes i ran into this issue several times.

It can be caused by a lot of stuff, sadly there is no general solution to this issue.

In summary, when you run into EXC_BAD_ACCESS, it means that you try to send a message to a block of memory that can't execute that message. In some cases, however, EXC_BAD_ACCESS is caused by a corrupt pointer. Whenever your application attempts to dereference a corrupt pointer, an exception is thrown by the kernel.

In my particular case (i think) i lost a pointer to a 3rd party library (Vuforia) which resulted in this crash:

Vuforia::init()
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000992616966020

This workflow helped me fix this issue. I think step 8. (keeping a reference to the unity module was the game changer)

Another time i had issues with combination of react-navigation and UnityModule.createUnity. You can read more here.

In my case it's related somehow with "validateTextureDimensions, line 1074: error 'MTLTextureDescriptor has width of zero.' validateTextureDimensions:1074: failed assertion `MTLTextureDescriptor has width of zero.' (lldb) " in UnityExport/Classes/Unity/MetalHelper.mm

Something related with resolution of a scene I think..

JanOwiesniak commented 5 years ago

Honestly i have no idea. Just because i'm reading UnityExport/Classes/Unity/MetalHelper.mm, have you tried to remove metal from the Graphics API?

IOS Platform:

Other Settings find the Rendering part, uncheck the Auto Graphics API and select only OpenGLES2.

https://github.com/f111fei/react-native-unity-view#configure-player-settings

alisherakb commented 5 years ago

Honestly i have no idea. Just because i'm reading UnityExport/Classes/Unity/MetalHelper.mm, have you tried to remove metal from the Graphics API?

IOS Platform: Other Settings find the Rendering part, uncheck the Auto Graphics API and select only OpenGLES2.

https://github.com/f111fei/react-native-unity-view#configure-player-settings

Downgrading react-native-unity-view to 1.2.1 fixed the issue. The newer versions create UnityNativeModule.h which causes somehow an error with our stack (Unity3d/ARFoundation + RN).

mistakelly commented 11 months ago

educative discussion, it did helped out.