stripe / stripe-ios

Stripe iOS SDK
https://stripe.com
MIT License
2.13k stars 984 forks source link

[BUG] crash when calling `StripeAPI.deviceSupportsApplePay()` #1984

Closed davidweissler closed 1 year ago

davidweissler commented 2 years ago

Summary

We're seeing crashes when calling StripeAPI.deviceSupportsApplePay()

Code to reproduce

The code is just a series of calls that ends with a call to StripeAPI.deviceSupportsApplePay()

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    ...
    AdNetworkHelper.reportAppOpenValue(sessionCount: count)
    ...
  }

  static func reportAppOpenValue(sessionCount: UInt) -> Int {
    let deviceSupportsApplePay = InAppProductManager.isStripeAvailable()
    ...
  }

  static func isStripeAvailable() -> Bool {
    return StripeAPI.deviceSupportsApplePay()
  }

iOS version

15.3.1 (19D52)

Installation method

SPM

SDK version

22.3.0

Other information

Example crash log

stripe_crash.txt

davidme-stripe commented 2 years ago

That's an odd crash — it looks like this is an iPad Air 2, and the Secure Element isn't responding during the [PKPaymentAuthorizationController canMakePaymentsUsingNetworks:] call, which is causing the app to hang during launch and eventually be killed by the system watchdog.

This sounds like an Apple bug, so I think the only thing we can do is file a Feedback Assistant ticket. How many of these crashes are you seeing? Are you able to reproduce it on your own devices?

davidweissler commented 2 years ago

In the last release of our app, it looks like there's about 30 devices crashing due to this.

CleanShot 2022-07-12 at 15 17 30@2x

I have tried a lot but have not been able to repro this myself unfortunately. And the crash occurs on varying devices, iPhones and iPads.

Edit to add: I guess I was also curious if other users have seen/reported this issue before, that you're aware of?

davidme-stripe commented 2 years ago

Edit to add: I guess I was also curious if other users have seen/reported this issue before, that you're aware of?

I have not, and I can't find any references to similar issues online. 😞

One idea: Could you try dispatching reportAppOpenValue to run slightly after launch? Here's a wild guess of what might be happening:

davidweissler commented 2 years ago

@davidme-stripe thanks for the suggestion! I was trying to see if some other code we might have been doing would cause the blocked thread. It might be a few weeks to test adding a delay in production, so let me know if it's ok to keep this issue open for a little bit and I can post an update here.

porter-stripe commented 1 year ago

@davidweissler closing this out for as stale, feel free to re-open if needed.

denggun commented 1 year ago

@davidweissler Hi,Have you solved this problem? I also encountered the same problem