FormidableLabs / react-native-app-auth

React native bridge for AppAuth - an SDK for communicating with OAuth2 providers
https://commerce.nearform.com/open-source/react-native-app-auth
MIT License
2.02k stars 440 forks source link

react-native-app-auth module getting crashed in Android #672

Closed BajrangS closed 8 months ago

BajrangS commented 3 years ago

Issue

Firebase crashlytics report below crash issue in react-native app Android. There is no issues in iOS.

Caused by java.lang.NullPointerException Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference

com.rnappauth.RNAppAuthModule.onActivityResult (RNAppAuthModule.java:414)


Environment

Please provide suggestions to fix this issue.

ghost commented 3 years ago

Here's the crash log from my app


java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
    at com.rnappauth.RNAppAuthModule.onActivityResult(RNAppAuthModule.java:419)
    at com.facebook.react.bridge.ReactContext.onActivityResult(ReactContext.java:305)
    at com.facebook.react.ReactInstanceManager.onActivityResult(ReactInstanceManager.java:762)
    at com.facebook.react.ReactDelegate.onActivityResult(ReactDelegate.java:90)
    at com.facebook.react.ReactActivityDelegate.onActivityResult(ReactActivityDelegate.java:112)
    at com.facebook.react.ReactActivity.onActivityResult(ReactActivity.java:68)
    at android.app.Activity.dispatchActivityResult(Activity.java:8304)
    at android.app.ActivityThread.deliverResults(ActivityThread.java:5006)
    at android.app.ActivityThread.handleSendResult(ActivityThread.java:5054)
    at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:223)
    at android.app.ActivityThread.main(ActivityThread.java:7664)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=52, result=-1, data=Intent { dat=com.****.auth0://callback?code=**** (has extras) }} to activity {com.****/com.****.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
    at android.app.ActivityThread.deliverResults(ActivityThread.java:5013)
    at android.app.ActivityThread.handleSendResult(ActivityThread.java:5054)
    at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:223)
    at android.app.ActivityThread.main(ActivityThread.java:7664)
    at java.lang.reflect.Method.invoke(Method.java)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
ghost commented 3 years ago

Same issue: https://github.com/FormidableLabs/react-native-app-auth/issues/600

mayzyo commented 2 years ago

This might be a different reason for crashing, but I was able to resolve my crash by adding in dangerouslyAllowInsecureHttpRequests: true

I don't know how to check android's native log so I am not sure if its the same error. But in my research to resolve my issue, I ended up here and issue #600 a couple times, so I hope this can help anyone suffering from the same error.

Jay-A-McBee commented 2 years ago

This issue occurs on low-end Android devices that kill the Activity when your app is backgrounded during the authentication process. We persist values in private instance fields so we can read/use them during the code/token exchange in our onActivityResult handler. We end up getting a null pointer exception because these values don't exist when we go to read them. Notice the first line in the posted stack trace

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference
    at com.rnappauth.RNAppAuthModule.onActivityResult(RNAppAuthModule.java:419)

I've talked with the other maintainers and we are going to try to get around to a fix for this. I can't provide a timeline, but just a heads up that it's on our radar. There are a few issues in the repo where this is the root cause.

jmacpherson commented 2 years ago

Also investigating this issue presently. Can't help but notice that while https://github.com/Nirodha26/react-native-app-auth/pull/1 put in what may be a fix for this issue in January, the releases since then have not included this update.

Edit: My mistake, I see that that is on a fork. Any chance of that getting merged into official?

DennisOstertag commented 2 years ago

Also investigating this issue presently. Can't help but notice that while Nirodha26#1 put in what may be a fix for this issue in January, the releases since then have not included this update.

Edit: My mistake, I see that that is on a fork. Any chance of that getting merged into official?

@Jay-A-McBee any chance this possible fix would resove the issue and can be merged here ?

nachoperez714 commented 2 years ago

It would be great if this fix was merged into official and added in a next release.

asami95 commented 2 years ago

Hello @Jay-A-McBee It does not just happen in low-end devices it also happens in so many high-end ones. Is there any chance to get the PR merged or solve this issue?

sandergo90 commented 2 years ago

Is there any update about this issue @Jay-A-McBee ?

asohail-futu commented 1 year ago

Are there any plans of including this change https://github.com/Nirodha26/react-native-app-auth/pull/1 in an official release to fix this issue?

kitingChris commented 1 year ago

Will this issue be fixed soon or is the library not longer maintained?

Cantinaband commented 1 year ago

We are facing the same issue. Any updates?

Crare commented 11 months ago

seeing similar errors in our App Center crash results:

com.rnappauth.RNAppAuthModule.onActivityResult RNAppAuthModule.java, line 504 java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference

main thread:

com.rnappauth.RNAppAuthModule.onActivityResult RNAppAuthModule.java:504
com.facebook.react.bridge.ReactContext.onActivityResult ReactContext.java:375
com.facebook.react.ReactInstanceManager.onActivityResult ReactInstanceManager.java:822
com.facebook.react.ReactDelegate.onActivityResult ReactDelegate.java:107
com.facebook.react.ReactActivityDelegate.onActivityResult ReactActivityDelegate.java:136
com.facebook.react.ReactActivity.onActivityResult ReactActivity.java:70
android.app.Activity.dispatchActivityResult Activity.java:8310
android.app.ActivityThread.deliverResults ActivityThread.java:5023
android.app.ActivityThread.handleSendResult ActivityThread.java:5071
android.app.servertransaction.ActivityResultItem.execute ActivityResultItem.java:51
android.app.servertransaction.TransactionExecutor.executeCallbacks TransactionExecutor.java:135
android.app.servertransaction.TransactionExecutor.execute TransactionExecutor.java:95
android.app.ActivityThread$H.handleMessage ActivityThread.java:2070
android.os.Handler.dispatchMessage Handler.java:106
android.os.Looper.loop Looper.java:223
android.app.ActivityThread.main ActivityThread.java:7711
java.lang.reflect.Method.invoke Method.java
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run RuntimeInit.java:592
com.android.internal.os.ZygoteInit.main ZygoteInit.java:952
android.app.ActivityThread.deliverResults ActivityThread.java:5030
android.app.ActivityThread.handleSendResult ActivityThread.java:5071
android.app.servertransaction.ActivityResultItem.execute ActivityResultItem.java:51
android.app.servertransaction.TransactionExecutor.executeCallbacks TransactionExecutor.java:135
android.app.servertransaction.TransactionExecutor.execute TransactionExecutor.java:95
android.app.ActivityThread$H.handleMessage ActivityThread.java:2070
android.os.Handler.dispatchMessage Handler.java:106
android.os.Looper.loop Looper.java:223
android.app.ActivityThread.main ActivityThread.java:7711
java.lang.reflect.Method.invoke Method.java
com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run RuntimeInit.java:592
com.android.internal.os.ZygoteInit.main ZygoteInit.java:952

From devices like:

We are using react-native-app-auth version 7.1.0, which is latest right now, but this has been happening for a while now.

We are also seeing some iOS errors too, but can't see any relation to this for now.

fikkatra commented 8 months ago

Same here, experiencing crashes on our production App. Mainly on HUAWEI P smart 2019, but others too, like Galaxy S21 5G and A52s 5G, Redmi Note 9 and 11 5G,...

More than 3 years since this issue was filed and still no fix, is this library still maintained actively?

RubenPM-dev commented 8 months ago

Experiencing the same issue even on the latest devices like the Galaxy S24 Ultra, any help would be appreciated.

Fatal Exception: java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=52, result=-1, data=Intent { dat=***app.auth://oauth/... (has extras) }} to activity {***app/***app.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference at android.app.ActivityThread.deliverResults(ActivityThread.java:6062) at android.app.ActivityThread.handleSendResult(ActivityThread.java:6101) at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:67) at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:139) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:96) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2685) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:230) at android.os.Looper.loop(Looper.java:319) at android.app.ActivityThread.main(ActivityThread.java:8918) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

nishadthajudeen001 commented 8 months ago

any update on this?

This happens on multiple production device( samsung q4q,OnePlus OnePlusN200TMO,motorola berlna,motorola denver etc)

Exception java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.Boolean.booleanValue()' on a null object reference at com.rnappauth.RNAppAuthModule.onActivityResult (RNAppAuthModule.java:492) at com.facebook.react.bridge.ReactContext.onActivityResult (ReactContext.java:338) at com.facebook.react.ReactInstanceManager.onActivityResult (ReactInstanceManager.java:824)

carbonrobot commented 8 months ago

Hi everyone, we don't currently have any resources able to take on this work, but are happy to accept PRs from the community.

RubenPM-dev commented 8 months ago

Hi everyone, we don't currently have any resources able to take on this work, but are happy to accept PRs from the community.

Thanks for all your work on this library, there are now a few PRs still open for a while. I have just submitted mine with the solution suggested by @yberstad which I can say it works on our end.

https://github.com/FormidableLabs/react-native-app-auth/issues/564

carbonrobot commented 8 months ago

@RubenPM-dev Thanks for the PR, we will review it as soon as possible.

carbonrobot commented 8 months ago

Released in https://github.com/FormidableLabs/react-native-app-auth/releases/tag/v7.1.1