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

Fix crash when React context activity is null #170

Merged
merged 1 commit into from
Jan 14, 2019

Conversation

artkow
Copy link
Contributor

@artkow artkow commented Dec 21, 2018

It fixes crash:
java.lang.AssertionError:
at com.facebook.infer.annotation.Assertions.assertNotNull()(Assertions.java:28)
at com.facebook.react.bridge.ReactContext.startActivityForResult()(ReactContext.java:326)
at io.underscope.react.fbak.RNAccountKitModule.login()(RNAccountKitModule.java:115)
at java.lang.reflect.Method.invoke()(Method.java:-2)
at com.facebook.react.bridge.JavaMethodWrapper.invoke()(JavaMethodWrapper.java:372)
at com.facebook.react.bridge.JavaModuleWrapper.invoke()(JavaModuleWrapper.java:160)
at com.facebook.react.bridge.queue.NativeRunnable.run()(NativeRunnable.java:-2)
at android.os.Handler.handleCallback()(Handler.java:790)
at android.os.Handler.dispatchMessage()(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage()(MessageQueueThreadHandler.java:29)
at android.os.Looper.loop()(Looper.java:164)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run()(MessageQueueThreadImpl.java:192)
at java.lang.Thread.run()(Thread.java:764)

Crash can be observed when RN app is launched and RNAccountKit.loginWithPhone is called from some ComponentDidMount. At the same time user press Home button to send RN app to bg.

When RN app is in background then method presented below throws error, which crash app:
public boolean startActivityForResult(Intent intent, int code, Bundle bundle) {
Activity activity = getCurrentActivity();
Assertions.assertNotNull(activity);
activity.startActivityForResult(intent, code, bundle);
return true;
}

@jpgarcia jpgarcia merged commit f3f22ea into Nubescope:master Jan 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants