braintree_android icon indicating copy to clipboard operation
braintree_android copied to clipboard

App crashes after tapping “Continue” on 3DS challenge screen in landscape mode

Open towfurious opened this issue 11 months ago • 2 comments

Braintree SDK Version

4.50.0

Environment

Production

Android Version & Device

Pixel 9 Pro XL - Android 15, Galaxy S25 Ultra - Android 15, Galaxy S22 - Android 14, Galaxy S20 FE - Android 13

Braintree dependencies

implementation 'com.braintreepayments.api:drop-in:6.17.0'
implementation 'com.braintreepayments.api:data-collector:4.50.0'
implementation 'com.braintreepayments.api:three-d-secure:4.50.0'

Describe the bug

Description:

When a user rotates the device to landscape orientation while on the 3DS challenge screen and taps the “Continue” button, the app crashes. This behavior occurs regardless of whether the user has confirmed the transaction in the bank’s app.

Important Note: • Simply rotating the device, minimizing the app (backgrounding), and returning does not cause a crash. • The crash only occurs when “Continue” is tapped in landscape mode.

Please see logs: java.lang.IllegalStateException: Attempting to launch an unregistered ActivityResultLauncher with contract androidx.activity.result.contract.ActivityResultContracts$StartActivityForResult@778822b and input Intent { flg=0x4000000 cmp=/<REDACTED>/com.cardinalcommerce.shared.cs.userinterfaces.ChallengeNativeView (has extras) }. You must ensure the ActivityResultLauncher is registered before calling launch(). at androidx.activity.result.ActivityResultRegistry$2.launch(ActivityResultRegistry.java:166) at androidx.activity.result.ActivityResultLauncher.launch(ActivityResultLauncher.java:47) at com.cardinalcommerce.a.cca_continue.init(SourceFile:139) at com.cardinalcommerce.a.cca_continue.onCReqSuccess(SourceFile:236) at com.cardinalcommerce.a.values.cca_continue(SourceFile:81) at com.cardinalcommerce.a.setBaselineAlignBottom$4.run(SourceFile:119) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) at java.lang.Thread.run(Thread.java:1012)

Additional Info: We can see the same error logs but different scenario here We can see the same steps and similar behavior here

To reproduce

Steps to Reproduce: 1. Trigger a payment that requires 3DS challenge authentication. 2. When the 3DS challenge screen appears, rotate the device to landscape orientation. 3. Tap the “Continue” button. 4. Observe: the app crashes.

Expected behavior

Expected Result: The 3DS flow should complete without crashing the app, even in landscape mode.

Screenshots

No response

towfurious avatar May 19 '25 16:05 towfurious

Update:

i also checked previous build with dependencies:

implementation 'com.braintreepayments.api:drop-in:6.16.0'
implementation 'com.braintreepayments.api:data-collector:4.46.0'
implementation 'com.braintreepayments.api:three-d-secure:4.46.0'

same steps to reproduce with crash but different logs:

android.view.WindowLeaked: Activity com.braintreepayments.api.ThreeDSecureActivity has leaked window 
com.android.internal.policy.DecorView{22f8853 V.E...... R.....ID 0,0-662,557}[ThreeDSecureActivity] that was originally added here
    at android.view.ViewRootImpl.<init>(ViewRootImpl.java:1246)
    at android.view.ViewRootImpl.<init>(ViewRootImpl.java:1232)
    at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:428)
    at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:158)
    at android.app.Dialog.show(Dialog.java:352)
    at com.cardinalcommerce.shared.userinterfaces.ProgressDialog$1.run(SourceFile:42)
    at android.app.Activity.runOnUiThread(Activity.java:8000)
    at com.cardinalcommerce.shared.userinterfaces.ProgressDialog.show(SourceFile:39)
    at com.cardinalcommerce.a.init.init(SourceFile:177)
    at com.cardinalcommerce.a.init.init(SourceFile:101)
    at com.cardinalcommerce.a.init.getInstance(SourceFile:36)
    at com.cardinalcommerce.a.init$5.getInstance(SourceFile:63)
    at com.cardinalcommerce.a.init$5.onActivityResult(SourceFile:60)
    at androidx.activity.result.ActivityResultRegistry.doDispatch(ActivityResultRegistry.java:392)
    at androidx.activity.result.ActivityResultRegistry.dispatchResult(ActivityResultRegistry.java:351)
    at androidx.activity.ComponentActivity.onActivityResult(ComponentActivity.java:647)
    at androidx.fragment.app.FragmentActivity.onActivityResult(FragmentActivity.java:140)
    at android.app.Activity.onActivityResult(Activity.java:7494)
    at android.app.Activity.internalDispatchActivityResult(Activity.java:9379)
    at android.app.Activity.dispatchActivityResult(Activity.java:9356)
    at android.app.ActivityThread.deliverResults(ActivityThread.java:5867)
    at android.app.ActivityThread.performResumeActivity(ActivityThread.java:5296)
    at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:5342)
    at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:57)
    at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:60)
    at android.app.servertransaction.TransactionExecutor.executeLifecycleItem(TransactionExecutor.java:225)
    at android.app.servertransaction.TransactionExecutor.executeTransactionItems(TransactionExecutor.java:107)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:81)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2636)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loopOnce(Looper.java:232)
    at android.os.Looper.loop(Looper.java:317)
    at android.app.ActivityThread.main(ActivityThread.java:8705)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)
Caused by: java.lang.IllegalArgumentException: 
View=com.android.internal.policy.DecorView{22f8853 V.E...... R.....ID 0,0-662,557}[ThreeDSecureActivity] 
not attached to window manager
    at android.view.WindowManagerGlobal.findViewLocked(WindowManagerGlobal.java:575)
    at android.view.WindowManagerGlobal.removeView(WindowManagerGlobal.java:482)
    at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:216)
    at android.app.Dialog.dismissDialog(Dialog.java:404)
    at android.app.Dialog.dismiss(Dialog.java:386)
    at com.cardinalcommerce.shared.userinterfaces.ProgressDialog$2.run(SourceFile:52)
    at android.os.Handler.handleCallback(Handler.java:959)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loopOnce(Looper.java:232)
    at android.os.Looper.loop(Looper.java:317)
    at android.app.ActivityThread.main(ActivityThread.java:8705)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:580)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:886)

towfurious avatar May 19 '25 16:05 towfurious

Hey @towfurious - thanks for opening this issue. There's a known issue with the Cardinal SDK where the SDK crashes when changing device orientation. We're still waiting for a response from the owners of that SDK. We'll keep this issue open and will report here once we have a fix. Thanks for your patience!

tdchow avatar May 20 '25 15:05 tdchow