Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.1.1 throws unhandled exception - Crash #237

Closed
1 of 3 tasks
Qwin opened this issue Oct 20, 2021 · 6 comments
Closed
1 of 3 tasks

2.1.1 throws unhandled exception - Crash #237

Qwin opened this issue Oct 20, 2021 · 6 comments
Assignees
Labels
android Android related

Comments

@Qwin
Copy link

Qwin commented Oct 20, 2021

I'm submitting a:

  • Bug report
  • Feature request
  • Other (Describe below)

Current behavior

When using react-native-share library (7.2.0) and opening a share tab and then tapping on any of the services (gmail) and then going back to the app, Okta throws the following exception causing the app to crash, I debugged the code and it seems like onCancel is being invoked and queuedPromise is null.

 java.lang.NullPointerException: Attempt to invoke interface method 'void com.facebook.react.bridge.Promise.reject(java.lang.String, java.lang.String)' on a null object reference
        at com.oktareactnative.OktaSdkBridgeModule$4.onCancel(OktaSdkBridgeModule.java:527)
        at com.okta.oidc.clients.web.WebAuthClientImpl.lambda$processSignInResult$5$WebAuthClientImpl(WebAuthClientImpl.java:174)
        at com.okta.oidc.clients.web.-$$Lambda$WebAuthClientImpl$0_cBT7GLb2JTAuHwaE7paM-RoKQ.run(Unknown Source:2)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Expected behavior

Does not fire SignIn event on threadpool abrupt kill of task, does not crash on queuedPromise.

Minimal reproduction of the problem with instructions

  1. Add react-native-share 7.1.x or 7.2.0 to the project
  2. open new share tab in android click on gmail
  3. in gmail exit out and go back to the app
  4. Above crash happens

Extra information about the use case/user story you are trying to implement

After looking further I see that the ThreadExecutor somehow cancels the futureTask (somehow in conflict with the pools with the share library maybe) in webAuthClient. Causing the registerCallback in WebAuthClientImpl to be invoked with type SIGN_IN and result CANCELLED. Again nobody invoked SignIn so the queuedPromise is null thus a crash happens.

I added a simple if statement for queuedPromise as a test on the canceled method, which solved the crashing of course, and the app functions normally and the token is still valid as well. But I am puzzled as to what is happening here. Of course it would be great if you guys added a null check just for safety but honestly it should never fire.... its just a workaround afterall.

image

SyncWebAuthClient
image

This does not happen in version 1.12.1 of okta-react-native.

Environment

  • Package Version: 2.1.1
  • React Native Version: 0.64.2
  • OS: Mac OS / Android 11
  • Node version (node -v): v14.18.0
  • Other: "react-native-share": "^7.2.0"
@Qwin Qwin changed the title Okta 2.1.1 throws unhandled exception - Crash 2.1.1 throws unhandled exception - Crash Oct 20, 2021
@JayNewstrom
Copy link
Contributor

Thanks for the report.

@NikitaAvraimov-okta could you take a look?

@oleggnidets-okta oleggnidets-okta added the android Android related label Oct 20, 2021
@NikitaAvraimov-okta NikitaAvraimov-okta self-assigned this Oct 20, 2021
@NikitaAvraimov-okta
Copy link
Contributor

Internal ref 439256

@Qwin
Copy link
Author

Qwin commented Oct 25, 2021

Any updates on this ? (Just wondering if you figured something out ?)

Also wondering if we can get the temp fix of having a null check for now on queuedPromise so that it at least doesn't crash.

@NikitaAvraimov-okta
Copy link
Contributor

@Qwin sorry for the delay. Before the fix is released you can try editing your local OktaSdkBridgeModule.java replicating changes in related PR

@Qwin
Copy link
Author

Qwin commented Oct 28, 2021

@NikitaAvraimov-okta thank you, will try it out.

@NikitaAvraimov-okta
Copy link
Contributor

Fixed #239 , please reach out if there are other questions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Android related
Projects
None yet
Development

No branches or pull requests

4 participants