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

PopupBridge.mWebView / mContext null after process kill #26

Closed
herbeth1u opened this issue Jun 30, 2020 · 5 comments
Closed

PopupBridge.mWebView / mContext null after process kill #26

herbeth1u opened this issue Jun 30, 2020 · 5 comments

Comments

@herbeth1u
Copy link

General information

  • SDK/Library version: 2.0.0
  • Android Version and Device: Multiple devices from multiple OEMs (60% Xiaomi Mi A2 Lite, then BlackBerry, Sony and WIKO), all Android versions (6, 8, 9, 10).

Issue description

Hello again. After some tests following #25 , we've managed to reproduce the crash so we're creating a new issue as mentioned in the previous issue. The stacktrace as a reminder:

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.view.View.post(java.lang.Runnable)' on a null object reference
       at com.braintreepayments.popupbridge.PopupBridge.runJavaScriptInWebView(PopupBridge.java:100)
       at com.braintreepayments.popupbridge.PopupBridge.onBrowserSwitchResult(PopupBridge.java:153)
       at com.braintreepayments.browserswitch.BrowserSwitchFragment.onResume(BrowserSwitchFragment.java:73)
       at androidx.fragment.app.Fragment.performResume(Fragment.java:2747)
       at androidx.fragment.app.FragmentStateManager.resume(FragmentStateManager.java:373)
       at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1199)
       at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1356)
       at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1434)
       at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1497)
       at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2625)
       at androidx.fragment.app.FragmentManager.dispatchResume(FragmentManager.java:2589)
       at androidx.fragment.app.FragmentController.dispatchResume(FragmentController.java:269)
       at androidx.fragment.app.FragmentActivity.onResumeFragments(FragmentActivity.java:478)
       at androidx.fragment.app.FragmentActivity.onPostResume(FragmentActivity.java:467)
       at androidx.appcompat.app.AppCompatActivity.onPostResume(AppCompatActivity.java:195)
       at android.app.Activity.performResume(Activity.java:7184)
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3694)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3766)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2939)
       at android.app.ActivityThread.-wrap11(ActivityThread.java)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1615)
       at android.os.Handler.dispatchMessage(Handler.java:105)
       at android.os.Looper.loop(Looper.java:231)
       at android.app.ActivityThread.main(ActivityThread.java:6749)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

Steps to reproduce

FYI we are using PopupBridge for Paypal.

  1. Initialize the SDK as mentioned in the docs (at this point we've made sure our webview cannot be null) :
webView?.let { PopupBridge.newInstance(activity, it) }
  1. Click on "Buy with Paypal" : the Paypal Chrome Tabs opens.
  2. Log in to Paypal if necessary but don't click on "Buy".
  3. Trigger a process kill (see here for more information on how to simulate a process kill).
  4. Go back to the application : the Paypal Chrome Tabs restarts and loads again properly.
  5. Click on "Buy".
  6. The PopupBridge fragment is recreated, but its data initialized in newInstance and not saved in a Bundle have been erased (including mWebView and mContext). When going in onResume, the NPE occurs.

Again feel free to ask for more details!
Thank you.

@sshropshire
Copy link
Contributor

Hi @herbeth1u thanks again for using the sdk. I tried reproducing in our demo application and am unable to reproduce. I do however see the concern. May I trouble you for a screen-capture as well?

Theoretically, I'm unable to imagine how WebView can become null if you're certain that a non-null reference is being passed into the PopupBridge::newInstance method.

@herbeth1u
Copy link
Author

Hi @sshropshire , we have recorded a video showcasing the crash. For obvious confidentiality issues, we would like to forward it to you in a private message. However it doesn't seem to be possible to send a PM on Github.
Do you perhaps have a public email address or any other private means of communication so we can send you the video?
Thanks.

@sshropshire
Copy link
Contributor

Hello @herbeth1u apologies for the late response. We are able to reproduce similar behavior in our demo application, and it has to do with the deep link back into the PopupBridgeActivity. It seems that Android isn't invoking the deep link after a process kill. We are investigating the issue.

@sarahkoop
Copy link
Contributor

This fix is released in 4.0.0-beta2.

@sshropshire
Copy link
Contributor

Version 4.0.0 is now generally available.

dpa99c added a commit to dpa99c/popup-bridge-android that referenced this issue Aug 6, 2021
dpa99c added a commit to dpa99c/cordova-plugin-inappbrowser-popup-bridge that referenced this issue Aug 6, 2021
…shfix: Wait for Window to Load Before Executing Javascript Callback.

Patched from v4 commit: braintree/popup-bridge-android@4bff178
Resolves: braintree/popup-bridge-android#26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants