sumup / sumup-android-sdk

Sample App for the SumUp Android SDK
Other
105 stars 28 forks source link

android.view.WindowLeaked: Activity com.sumup.merchant.reader.ui.activities.CardReaderPaymentAPIDrivenPageActivity has leaked window DecorView@974c875[CardReaderPaymentAPIDrivenPageActivity] #147

Open steveetm opened 3 years ago

steveetm commented 3 years ago

I had to upgrade from 3.2.0 to 3.3.0 and getting this runtime error since then. We use this sdk in a cordova plugin like this:

      SumUpPayment payment = SumUpPayment.builder()
        .total(amount)
        .currency(currency)
        .title(title)
        .skipSuccessScreen()
        .build();

      Runnable runnable = () -> {
        SumUpAPI.checkout(cordova.getActivity(), payment, REQUEST_CODE_PAYMENT);
      };

      callback = callbackContext;
      cordova.setActivityResultCallback(this);
      cordova.getActivity().runOnUiThread(runnable);

This was working fine with 3.2.0, but since 3.3.0 I get the error in the title, with the following stack:

 E WindowManager: android.view.WindowLeaked: Activity com.sumup.merchant.reader.ui.activities.CardReaderPaymentAPIDrivenPageActivity has leaked window DecorView@974c875[CardReaderPaymentAPIDrivenPageActivity] that was originally added here
    at android.view.ViewRootImpl.<init>(ViewRootImpl.java:793)
    at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:461)
    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:95)
    at android.app.Dialog.show(Dialog.java:507)
    at com.sumup.merchant.reader.helpers.ProgressDialogHelper.createDialog(SourceFile:15)
    at com.sumup.merchant.reader.helpers.ProgressDialogHelper.getDialog(SourceFile:20)
    at com.sumup.merchant.reader.helpers.ProgressDialogHelper.getDialog(SourceFile:24)
    at com.sumup.merchant.reader.helpers.ProgressDialogHelper.getProcessingDialog(SourceFile:29)
    at com.sumup.merchant.reader.ui.activities.CardReaderPaymentAPIDrivenPageActivity.sendTerminalSDKCheckoutRequest(SourceFile:356)
    at com.sumup.merchant.reader.ui.activities.CardReaderPaymentAPIDrivenPageActivity.onSafeCreate(SourceFile:152)
    at com.sumup.merchant.reader.ui.activities.SumUpReaderModuleBaseActivity.onCreate(SourceFile:50)
    at android.app.Activity.performCreate(Activity.java:7963)
    at android.app.Activity.performCreate(Activity.java:7952)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3629)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3806)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
    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:2267)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:237)
    at android.app.ActivityThread.main(ActivityThread.java:8167)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

Before this call we check if the user is already logged in with this:

 Runnable runnable = () -> {
        callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, SumUpAPI.isLoggedIn()));
      };
      cordova.getActivity().runOnUiThread(runnable);

Which works fine

Any suggestions? I couldn't find much info in the release notes of 3.3.0:/ Thanks in advance.