react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

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

Open marf opened this issue 2 years ago • 15 comments

🐛 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!

marf avatar May 24 '22 15:05 marf

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)

YazeedAsaad avatar May 29 '22 08:05 YazeedAsaad

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

marf avatar Jun 14 '22 08:06 marf

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

YazeedAsaad avatar Jun 14 '22 13:06 YazeedAsaad

@YazeedAsaad , you know why am here

ali-sao avatar Jul 03 '22 17:07 ali-sao

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)

manuhook avatar Jul 12 '22 17:07 manuhook

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)

SYoder1 avatar Jul 14 '22 15:07 SYoder1

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

manuhook avatar Jul 27 '22 07:07 manuhook

Any thoughts or ideas on how to fix this?

marf avatar Sep 07 '22 15:09 marf

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)

tarouboy avatar Jan 20 '23 09:01 tarouboy

@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

N3TC4T avatar Mar 07 '23 12:03 N3TC4T

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

mcapocaccia avatar Mar 08 '23 17:03 mcapocaccia

@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

mcapocaccia avatar Mar 08 '23 17:03 mcapocaccia

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 avatar Sep 27 '23 20:09 gigby

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.

gigby avatar Sep 27 '23 20:09 gigby

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

PaoloSalta avatar Dec 29 '23 09:12 PaoloSalta