Adyen / adyen-3ds2-android

Apache License 2.0
26 stars 8 forks source link

IllegalStateException: Can not perform this action after onSaveInstanceState #30

Closed mikkoville closed 3 years ago

mikkoville commented 3 years ago

Version:2.2.0

We are getting quite many reports in our crash reporting about following:

Fatal Exception: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
       at androidx.fragment.app.FragmentManager.checkStateLoss(FragmentManager.java:1703)
       at androidx.fragment.app.FragmentManager.enqueueAction(FragmentManager.java:1743)
       at androidx.fragment.app.BackStackRecord.commitInternal(BackStackRecord.java:321)
       at androidx.fragment.app.BackStackRecord.commit(BackStackRecord.java:286)
       at androidx.fragment.app.DialogFragment.dismissInternal(DialogFragment.java:276)
       at androidx.fragment.app.DialogFragment.dismiss(DialogFragment.java:228)
       at com.adyen.threeds2.internal.ui.activity.a$1.run(a.java:105)
       at android.os.Handler.handleCallback(Handler.java:883)
       at android.os.Handler.dispatchMessage(Handler.java:100)
       at android.os.Looper.loop(Looper.java:237)
       at android.app.ActivityThread.main(ActivityThread.java:8167)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)

Havent been able to reproduce locally but could it be that is in background (user is visiting some other app) and Adyen SDk tries to dismiss the dialog for some reason?

caiofaustino commented 3 years ago

Thx for the details, we will investigate this scenario.

salah-ghanim commented 3 years ago

@caiofaustino we see the exception on our side too, any chance a simple try and catch is shipped while you guys investigate? crashing the app fully during onboarding for a screen that shouldn't save state anyway seems a bit extreme

caiofaustino commented 3 years ago

Sorry for the delay on this, the delay was not really about the fix itself but the migration to Maven Central so that we can release there instead. We will provide a release asap.

caiofaustino commented 3 years ago

Question, are you guys using mTransaction.getProgressView() to show and hide the loading on your own Activity?

mikkoville commented 3 years ago

@caiofaustino We are not using Transaction.getProgressView() at all in our impl.

We basically:

  1. Create transaction
  2. Call transaction.doChallenge
  3. After challenge returns in ChallengeStatusReceiver we cleanup with:
    transaction?.close()
    transaction = null
    service.cleanup(usedActivity)
caiofaustino commented 3 years ago

Thanks :)

caiofaustino commented 3 years ago

Released the fix on 2.2.2 if you could test please.

mikkoville commented 3 years ago

@caiofaustino Thanks will update and report if happens again

mikkoville commented 3 years ago

@caiofaustino We just got crash report from app version using version2.2.2 so looks like the issue still persists.

Fatal Exception: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
       at androidx.fragment.app.FragmentManager.checkStateLoss(FragmentManager.java:1703)
       at androidx.fragment.app.FragmentManager.enqueueAction(FragmentManager.java:1743)
       at androidx.fragment.app.BackStackRecord.commitInternal(BackStackRecord.java:321)
       at androidx.fragment.app.BackStackRecord.commit(BackStackRecord.java:286)
       at androidx.fragment.app.DialogFragment.dismissInternal(DialogFragment.java:276)
       at androidx.fragment.app.DialogFragment.dismiss(DialogFragment.java:228)
       at com.adyen.threeds2.internal.ui.activity.a$a.run(a.java:2)
       at android.os.Handler.handleCallback(Handler.java:938)
       at android.os.Handler.dispatchMessage(Handler.java:99)
       at android.os.Looper.loop(Looper.java:246)
       at android.app.ActivityThread.main(ActivityThread.java:8512)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

Brand:samsung Model:Galaxy S21 Ultra 5G Operating System Version:11 Rooted:No

jreij commented 3 years ago

Issue resurfaced in 2.2.2.

caiofaustino commented 3 years ago

I made another fix that should solve the issue in 2.2.3