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

App Crashes on Version 6.23.0..6.23.2 when adding account while timeouts on 6.23.3..6.23.4 #1422

Open
initishbhatt opened this issue Sep 27, 2024 · 10 comments

Comments

@initishbhatt
Copy link

Braintree SDK Version

6.23.2

Environment

Sandbox

Xcode Version

Xcode 15.4

OS Version & Device

iPhone 15Pro 17.6

Integration type

CocoaPods

Development Processor

Apple Silicon (M-series chips)

Describe the bug

I am experiencing a critical issue with the Braintree iOS SDK versions 6.23.0 through 6.23.2, where the app crashes when attempting to add an account. The crash seems to be related to the analytics handling within the SDK, particularly in the sendQueuedAnalyticsEvents function.

Additionally, after upgrading to versions 6.23.3 and 6.23.4, I am encountering timeouts when performing similar operations, which prevents successful account addition.

To reproduce

Steps to Reproduce:

  • Integrate Braintree SDK version 6.23.0 to 6.23.2 into an iOS application.
  • Attempt to add an account using the provided integration methods.
  • Observe that the application crashes during this process.
  • Upgrade to versions 6.23.3 or 6.23.4.
  • Attempt the same account addition operation.
  • Notice that the app does not crash but instead times out.

Expected behavior

Expected Behavior:
The app should allow for successful account addition without crashing or timing out.

Screenshots

No response

@KunJeongPark
Copy link
Contributor

KunJeongPark commented Sep 27, 2024

Hello. Can you tell me exactly which function you are calling? Do you mean PayPal account tokenization?
Checkout or vaulting (saving payment method)? Code snippets you used from our SDK would be helpful.

Please specify exactly which flow in our Braintree iOS SDK you are invoking. If you can reproduce this in our demo app and upload a video, it would be most helpful.
Also output warnings or error outputs you have would also be helpful in trying to identify the issue.

The crashes in 6.23.2 is a known issue. We will try to see if we can reproduce the issue on 6.23.3+ with more information from you.

Thank you!

@initishbhatt
Copy link
Author

Hello, we use vaulting BTPayPalVaultRequest. the issue occurs with tokenising BTPayPalClient. i'll try with the demo app to try and reproduce the issue and also get some output logs from our app

@KunJeongPark
Copy link
Contributor

Thank you. A video of what happens in the demo app would be helpful as well.

@initishbhatt
Copy link
Author

initishbhatt commented Oct 7, 2024

i am not able to reproduce it in the demo app but from debugging our app i got the following info

The function getConfig() times out before completion, resulting in the following errors:

API MISUSE: Resuming an NSURLSessionTask with nil URL.
httpCanHandleRequest(): Called for a nullptr request!
_canHandleRequest(): called with a NULL request
_canHandleRequest(): called with a NULL request
assertion failure
Task <[TaskID]>.<1> finished with error [-1001] Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." 
UserInfo={_NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <[TaskID]>.<1>, _kCFStreamErrorDomainKey=4, _kCFStreamErrorCodeKey=-2103, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <[TaskID]>.<1>"
), NSLocalizedDescription=The request timed out.}

The error suggests that the NSURLSessionTask is resuming with a nil URL, which eventually causes the request to time out.

@KunJeongPark
Copy link
Contributor

KunJeongPark commented Oct 7, 2024

Thank you for the information. That is very helpful.
How often does this occur in your app? Does this happen all the time? Are you able to get vault working at all?
Can you provide us with pseudo code of how you initialize BTAPIClient and BTPayPalClient and your BTPayPalVaultRequest in your app?

Does this only happen with vault operation in your app or also with other methods in your app like PayPal Checkout (tokenize with PayPalCheckoutRequest) or tokenize with Card?

We are still working on reproducing this error with our demo app.

@initishbhatt
Copy link
Author

initishbhatt commented Oct 8, 2024

  1. How often does this occur in your app?

    • We can reproduce this issue 100% of the time (3 out of 3 attempts).
    • It happens consistently every time we try to use the PayPal vault feature.
  2. Does this happen all the time?

    • Yes, it occurs every time we attempt to use the PayPal vault functionality.
  3. Are you able to get vault working at all?

    • No, we are not able to get the vault working at all.
    • We consistently experience timeouts when attempting to use the vault feature.
  4. Does this only happen with vault operation in your app or also with other methods?

    • We exclusively use Braintree for PayPal vault in our app.
    • We do not use other Braintree methods like PayPal Checkout or Card tokenization.

Here's the pseudo-code showing how we initialize BTAPIClient, BTPayPalClient, and BTPayPalVaultRequest in our app:

func initializeAndVaultPayPal(token: String) {
    // Initialize BTAPIClient
    guard let braintreeAPIClient = BTAPIClient(authorization: token) else {
        // Handle initialization failure
        return
    }

    // Create BTPayPalVaultRequest
    let request = BTPayPalVaultRequest()

    // Initialize BTPayPalClient
    let braintreePayPalClient = BTPayPalClient(apiClient: braintreeAPIClient)

    // Attempt to tokenize
    braintreePayPalClient.tokenize(request) { payPalAccountNonce, error in
        if let error = error {
            // Handle error 
            return
        }

        guard let nonce = payPalAccountNonce?.nonce else {
            // Handle missing nonce
            return
        }

        // Process successful tokenization
    }
}

This function is called after we've obtained a client token from our server:

func addPayPalAccount() {
    paymentMethodManager.initializeBraintree { token in
        if let token = token {
            initializeAndVaultPayPal(token: token)
        } else {
            // Handle token retrieval failure
        }
    }
}

@KunJeongPark
Copy link
Contributor

KunJeongPark commented Oct 8, 2024

Thank you. We are investigating.

Would you be able to file this issue on https://developer.paypal.com/braintree/help as well so
you can provide relevant ID's and app name. This will help us track down your transaction in our logs.

Also, are you using tokenization key or client token to initialize the BTAPIClient?

@initishbhatt
Copy link
Author

sure i'll file the issue there. we use client token to initialize the BTAPIClient

@initishbhatt
Copy link
Author

also we downgraded to 6.18.2 and its working for us there both on sandbox and production

@KunJeongPark
Copy link
Contributor

KunJeongPark commented Oct 9, 2024

That's very helpful. Thank you for your patience. We will look out for your issue to track down your transaction in our logs.

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

No branches or pull requests

2 participants