wix / react-native-navigation

A complete native navigation solution for React Native
https://wix.github.io/react-native-navigation/
MIT License
13.04k stars 2.67k forks source link

Attempt to invoke virtual method 'dx1 bw1.g()' on a null object reference #7531

Open marf opened 2 years ago

marf commented 2 years ago

🐛 Bug Report

Hello, we see this crash on Android mobile devices.

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'dx1 bw1.g()' on a null object reference
       at com.reactnativenavigation.react.NavigationModule.navigator(NavigationModule.java:213)
       at com.reactnativenavigation.react.NavigationModule.access$100(NavigationModule.java:39)
       at com.reactnativenavigation.react.NavigationModule$1.lambda$onHostPause$0(NavigationModule.java:62)
       at com.reactnativenavigation.react.NavigationModule$1.$r8$lambda$188Rw-Gn_-JcbOeFEeH40BTzx_c(NavigationModule.java)
       at com.reactnativenavigation.react.NavigationModule$1$$InternalSyntheticLambda$0$b0197b1cf9fbe4d3c36c604e9bf2d7984edd8cd7c195b97aa17cf10b52497c8e$0.run(NavigationModule.java:2)
       at android.os.Handler.handleCallback(Handler.java:789)
       at android.os.Handler.dispatchMessage(Handler.java:98)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6944)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

We use RN 0.68 and RNN 7.28.0.

Any ideas on how to solve this?

Thanks!

YazeedAsaad commented 2 years ago

encountering same issue here after upgrading to 0.68 , the crash is also happening on RNN versions (7.21.0,7.26.0,7.27.1) (we tried downgrading to resolve the issue but it seems related to RN 0.68 with RNN mainly, the error stack is kind of the same but we get:

java.lang.NullPointerException: Attempt to invoke virtual method 'com.reactnativenavigation.viewcontrollers.navigator.Navigator com.reactnativenavigation.NavigationActivity.getNavigator()' on a null object reference at com.reactnativenavigation.react.NavigationModule.navigator(NavigationModule.java:213) at com.reactnativenavigation.react.NavigationModule.access$100(NavigationModule.java:39) at com.reactnativenavigation.react.NavigationModule$1.lambda$onHostResume$1$com-reactnativenavigation-react-NavigationModule$1(NavigationModule.java:75) at com.reactnativenavigation.react.NavigationModule$1$$ExternalSyntheticLambda1.run(Unknown:2) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7356) at java.lang.reflect.Method.invoke(Method.java:-2) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

marf commented 2 years ago

Any workaround or quick fix? We see lot of crashes in our app because of this problem :(

YazeedAsaad commented 2 years ago

Sadly we are still encountring a huge number of crashes on our prod app as well and starting considering downgrading react native as it seems this issue is being ignored

ali-sao commented 2 years ago

@YazeedAsaad , you know why am here

manuhook commented 2 years ago

Same problem on our app.

@YazeedAsaad what was your last working version without this issue ? for us rnn 7.23.1 and rn 0.66.3 was fine Now we are using 7.28.0 and still rn 0.66.3 and we have this problem. Thanks !

Non-fatal Exception: io.invertase.firebase.crashlytics.JavaScriptError: java.lang.NullPointerException: Attempt to invoke virtual method 'com.reactnativenavigation.viewcontrollers.navigator.Navigator com.reactnativenavigation.NavigationActivity.getNavigator()' on a null object reference
    at com.reactnativenavigation.react.NavigationModule.navigator(NavigationModule.java:213)
    at com.reactnativenavigation.react.NavigationModule.access$100(NavigationModule.java:39)
    at com.reactnativenavigation.react.NavigationModule$1.lambda$onHostPause$0(NavigationModule.java:62)
    at com.reactnativenavigation.react.NavigationModule$1.lambda$onHostPause$0$NavigationModule$1(NavigationModule.java)
    at com.reactnativenavigation.react.-$$Lambda$NavigationModule$1$188Rw-Gn_-JcbOeFEeH40BTzx_c.run(lambda)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6134)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

       at .<unknown>(.java)
       at .<unknown>(.java)
       at .<unknown>(.java)
       at .<unknown>(.java)
       at .<unknown>(.java)
       at .<unknown>(.java)
       at .<unknown>(.java)
       at .<unknown>(.java)
       at .<unknown>(.java)
       at .<unknown>(.java)
       at .anonymous(.java)
       at .apply(.java)
       at .__invokeCallback(.java)
       at .anonymous(.java)
       at .__guard(.java)
       at .invokeCallbackAndReturnFlushedQueue(.java)
SYoder1 commented 2 years ago

I am seeing the same issue as well, across different OS versions. 6.0.1 all the way to 12.

"react-native": "0.68.2", "react-native-navigation": "7.28.0",


java.lang.NullPointerException: Attempt to invoke virtual method 'com.reactnativenavigation.viewcontrollers.navigator.Navigator com.reactnativenavigation.NavigationActivity.getNavigator()' on a null object reference
        at com.reactnativenavigation.react.NavigationModule.navigator(NavigationModule.java:213)
        at com.reactnativenavigation.react.NavigationModule.access$100(NavigationModule.java:39)
        at com.reactnativenavigation.react.NavigationModule$1.lambda$onHostPause$0$com-reactnativenavigation-react-NavigationModule$1(NavigationModule.java:62)
        at com.reactnativenavigation.react.NavigationModule$1$$ExternalSyntheticLambda0.run(Unknown:2)
        at android.os.Handler.handleCallback(Handler.java:978)
        at android.os.Handler.dispatchMessage(Handler.java:104)
        at android.os.Looper.loopOnce(Looper.java:238)
        at android.os.Looper.loop(Looper.java:357)
        at android.app.ActivityThread.main(ActivityThread.java:8090)
        at java.lang.reflect.Method.invoke(Method.java:-2)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1026)
manuhook commented 2 years ago

Hi @guyca, please can you check this issue with getNavigator() ? seems it has been already fixed once in the past : https://github.com/wix/react-native-navigation/issues/5996

marf commented 2 years ago

Any thoughts or ideas on how to fix this?

tarouboy commented 1 year ago

We're still getting this error on production after upgrading to latest version, couldn't reproduce it tho.

RN 0.70.6 RNN 7.30.3

Fatal Exception: java.lang.NullPointerException
Attempt to invoke virtual method 'com.reactnativenavigation.viewcontrollers.navigator.Navigator com.reactnativenavigation.NavigationActivity.getNavigator()' on a null object reference
com.reactnativenavigation.react.NavigationModule.navigator (NavigationModule.java:213)
com.reactnativenavigation.react.NavigationModule.access$100 (NavigationModule.java:39)
com.reactnativenavigation.react.NavigationModule$1.lambda$onHostPause$0$com-reactnativenavigation-react-NavigationModule$1 (NavigationModule.java:62)
com.reactnativenavigation.react.NavigationModule$1$$ExternalSyntheticLambda0.run (Unknown Source:2)
N3TC4T commented 1 year ago

@guyca it seems that sometime the activity is null in onHostPause, can this https://github.com/wix/react-native-navigation/commit/910193051447c4e523896c7f6751e4e9633eba7a commit be the cause of this issue ?

we may also add the condition to check for null activity getCurrentActivity() != null https://github.com/wix/react-native-navigation/blob/438e10a3ee34120096394f7604b2693b76a49c12/lib/android/app/src/main/java/com/reactnativenavigation/react/NavigationModule.java#L62

mcapocaccia commented 1 year ago

Should be fixed by this patch https://github.com/wix/react-native-navigation/issues/7593#issuecomment-1245475643

mcapocaccia commented 1 year ago

@guyca it seems the patch I suggested in this link https://github.com/wix/react-native-navigation/issues/7593#issuecomment-1245475643 hasn't been fully applied even in the current master.

onHostPause and onHostResume are now indeed called in the main thread, but they still wrongly count on navigator() having a valid value.

I see several issues reporting crashes with different minimised names but all pointing at these methods

gigby commented 1 year ago

I got the same (or almost the same issue) on Android 12L device: java.lang.NullPointerException: Attempt to invoke virtual method 'com.reactnativenavigation.viewcontrollers.navigator.Navigator com.reactnativenavigation.NavigationActivity.getNavigator()' on a null object reference

RN: 0.68

buildToolsVersion = "31.0.0" minSdkVersion = 21 compileSdkVersion = 31 targetSdkVersion = 33

"react-native-navigation": "7.28.1",

gigby commented 1 year ago

We're still getting this error on production after upgrading to latest version, couldn't reproduce it tho.

RN 0.70.6 RNN 7.30.3

Fatal Exception: java.lang.NullPointerException
Attempt to invoke virtual method 'com.reactnativenavigation.viewcontrollers.navigator.Navigator com.reactnativenavigation.NavigationActivity.getNavigator()' on a null object reference
com.reactnativenavigation.react.NavigationModule.navigator (NavigationModule.java:213)
com.reactnativenavigation.react.NavigationModule.access$100 (NavigationModule.java:39)
com.reactnativenavigation.react.NavigationModule$1.lambda$onHostPause$0$com-reactnativenavigation-react-NavigationModule$1 (NavigationModule.java:62)
com.reactnativenavigation.react.NavigationModule$1$$ExternalSyntheticLambda0.run (Unknown Source:2)

Try to open your app via Samsung Galaxy Fold3/4/5 and you probably will able to see this issue.

PaoloSalta commented 9 months ago

We are getting a similar error, but we are not able to reproduce it.

RN 0.72.7 RNN 7.37.1

Fatal Exception: java.lang.RuntimeException Unable to pause activity {.........}: java.lang.NullPointerException: Attempt to invoke virtual method 'com.reactnativenavigation.viewcontrollers.navigator.Navigator com.reactnativenavigation.NavigationActivity.getNavigator()' on a null object reference