Purchases.purchasePackage(package) takes too long
- [X] I have updated Purchases SDK to the latest version
- [X] I have read the Contribution Guidelines
- [X] I have searched the Community
- [X] I have read docs.revenuecat.com
- [X] I have searched for existing Github issues
Environment
- [ ] Output of
flutter doctor`[✓] Flutter (Channel stable, 3.7.12, on macOS 13.0.1 22A400 darwin-x64, locale en-GB) • Flutter version 3.7.12 on channel stable at /Users/mac/Code/Flutter/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 4d9e56e694 (4 weeks ago), 2023-04-17 21:47:46 -0400 • Engine revision 1a65d409c7 • Dart version 2.19.6 • DevTools version 2.20.1
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at /Users/mac/Library/Android/sdk • Platform android-33, build-tools 33.0.0 • Java binary at: /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java • Java version Java(TM) SE Runtime Environment (build 1.8.0_361-b09) • All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 14E222b • CocoaPods version 1.12.1
[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[!] Android Studio (not installed) • Android Studio not found; download from https://developer.android.com/studio/index.html (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
[✓] VS Code (version 1.78.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.64.0
[✓] Connected device (3 available) • iPhone 14 Pro Max (mobile) • 0BC2EBC6-CF53-4D82-96C2-16475ED01166 • ios • com.apple.CoreSimulator.SimRuntime.iOS-16-4 (simulator) • macOS (desktop) • macos • darwin-x64 • macOS 13.0.1 22A400 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 113.0.5672.126
[✓] HTTP Host Availability • All required HTTP hosts are available`
- [x] Version of
purchases-flutter
4.12.0
- [x] Testing device version e.g.: iOS 15.5, Android API 30, etc.
iOS 16.4
-
[x] How often the issue occurs- every one of your customers is impacted? Only in dev? DEV AND PROD
-
[ ] Debug logs that reproduce the issue
-
[ ] Steps to reproduce, with a description of expected vs. actual behavior Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)
Describe the bug
Our flutter/ios app is taking ~8 seconds to load the iOS payment page, on android it is instantaneous. The purchase goes through after the delay but the response also taker longer. This has barred us from deploying the app to apple store.
Additional context
Add any other context about the problem here.
👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!
Hi, this is happening from Apple's end. This is most likely from a iOS sandbox user with a lot of receipts so it is causing a delay. I recommend you try making a new sandbox user, this should remove the delay.
Hello, this is happening in production. We are not using sandbox users.
Could you share debug logs when you reproduce the issue?
iOS app is taking ~8 seconds to load the iOS payment page
Could you describe what exactly takes 8 seconds? Is it the time from the user entering AppStore credentials or accepting the purchase until the time your flutter app receives the confirmation? Or the time between accepting the purchase and receiving the "purchase success" alert from iOS?
Hello, I'm having the exact same problem.
When I click the button to make the purchase, in Android works perfectly, in iOs it takes ~4 to 5 seconds to show the Apple payment modal. It doesn't show any error on the console.
Lib version: 4.12.0
Flutter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.7.12, on macOS 13.3.1 22E772610a darwin-arm64
(Rosetta), locale en-BR)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.2)
[✓] VS Code (version 1.78.2)
Scanning for devices is taking a long time...[✓] Connected device (3 available)
[✓] HTTP Host Availability
• No issues found!
It would be helpful if you could attached debug logs as well as the code you're using to call purchase. Thanks!
I used await Purchases.purchasePackage(plan); to call when I click the button and then, it showed the following logs:
[Purchases] - DEBUG: ℹ️ Vending Offerings from cache
[Purchases] - INFO: 💰 Purchasing Product 'product' from package in Offering 'default_offering'
[Purchases] - DEBUG: ℹ️ Adding payment for product 'product'. 0 transactions already in the queue.
[Purchases] - DEBUG: ℹ️ StoreKit1Wrapper (0x00000002803d5260) updatedTransaction: product 0
@NachoSoto hey! Do you have any updates on this? I'm still having this problem (same log as before)
My guess is the delay happens between the "adding payment" and "updated transaction" logs. Can you confirm that?
Is there any update on this? seeing this in dev
The delay on iOS is really too long. As a palliative solution, I block the UI with a loader and call the purchasePackage only after UI is already blocked, but there will be a loader layer on top of another loader in the bottom sheet, a weird experience, because I can't dismiss the first loader from the layer down and keep visible due to opacity from de second layer.
I also tested if it was possible to get the in app purchase screen from the hierarchy of components above, using an observable notification, but as it is native code it is not a simple task to detect when it is launched on the screen, and there isn't another method that triggers any action at the exact moment the native bottom sheet payment is shown.
It happens for me for both production and new sandbox user. After calling the purchasePackage function it takes ~ 7 seconds until iOS payment page loads. Tested it both with 5.0.0 and 4.13.0
Since it takes a lot of time to load and complete the purchase the abandonment rate is very high and people do not complete payment!! if there's no solution I would have to switch to other company
I just tested this and the delay is less than 1 second both on simulator (iOS 16.4) and on device (iOS 17.0 beta 1). Also tested on the iOS 14.4 simulator with no issues.
When you reproduce this, could you pause the debugger on Xcode and send us a trace of what all the threads look like?
I just randomly saw this from a completely different app (not even Flutter).
I confirmed that the delay happens after we call SKPaymentQueue.add(payment), and none of the threads are locked or anything. Meaning the delay is entirely on Apple's side.
Also confirmed this happens even without our SDK, same delay on both StoreKit 1 and StoreKit 2.
I just filed FB12402539 to Apple including my device diagnostics. I recommend you do the same to maximize the chances of Apple fixing this.
@NachoSoto Thanks for the update
@NachoSoto this is not a random delay, it is a consistent delay. We just updated from flutter_purchases: 4.11.1 to 5.3.0. The older version was not slow, the new version is slow. We are forced to upgrade soon but my company is concerned about this delay causing churn.
@NachoSoto I am facing the same issue. The await for purchase package never completes
I’d appreciate it if you could provide any additional details to help us debug this 🙏
@NachoSoto This is the logs that I get
[tcp] tcp_input [C1.1.1.1:3] flags=[R] seq=817168140, ack=0, win=0 state=LAST_ACK rcv_nxt=817168140, snd_una=3717549969
[tcp] tcp_input [C1.1.1.1:3] flags=[R] seq=817168140, ack=0, win=0 state=CLOSED rcv_nxt=817168140, snd_una=3717549969
[Purchases] - DEBUG: ℹ️ applicationDidBecomeActive
[Purchases] - DEBUG: ℹ️ applicationDidBecomeActive
[Purchases] - DEBUG: ℹ️ StoreKit1Wrapper (0x00000002809e3f00) updatedTransaction: rc_premium_monthly 2000000373185658 1
flutter: ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
flutter: │ #0 SettingsProvider.setListenerForInAppPurchases.<anonymous closure> (package:feedbackai/modules/settings/providers/settings_provider.dart:117:20)
flutter: │ #1 _RootZone.runUnaryGuarded (dart:async/zone.dart:1593:10)
flutter: ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
flutter: │ 🐛 Purchase successful!
flutter: └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
[Purchases] - DEBUG: ℹ️ Found 0 unsynced attributes for App User ID: $RCAnonymousID:8f248f4495ab439ebe689ce73bf72647
[Purchases] - DEBUG: ℹ️ Force refreshing the receipt to get latest transactions from Apple.
[Purchases] - DEBUG: ℹ️ SKReceiptRefreshRequest started
[] nw_path_necp_check_for_updates Failed to copy updated result (22)
[Purchases] - DEBUG: ℹ️ StoreKit1Wrapper (0x00000002809e3f00) removedTransaction: rc_premium_monthly 2000000373185658 1
[Purchases] - DEBUG: ℹ️ StoreKit1Wrapper (0x00000002809e3f00) removedTransaction for (rc_premium_monthly but not callbacks to notify
<SKReceiptRefreshRequest: 0x282d474c0>: Finished refreshing receipt with error: Error Domain=ASDErrorDomain Code=603 "Request throttled" UserInfo={NSLocalizedFailureReason=Unified receipt is valid and current, NSLocalizedDescription=Request throttled, AMSServerErrorCode=0}
[Purchases] - DEBUG: ℹ️ SKReceiptRefreshRequest finished
[Purchases] - DEBUG: ℹ️ Loaded receipt from url file:///private/var/mobile/Containers/Data/Application/E9DB90F5-0134-40CE-B4E5-965698565CDB/StoreKit/sandboxReceipt
[Purchases] - DEBUG: ℹ️ Skipping products request for these products because they were already cached: ["rc_premium_monthly"]
[Purchases] - DEBUG: ℹ️ PostReceiptDataOperation: Started
[Purchases] - INFO: ℹ️ Parsing receipt
[Purchases] - INFO: ℹ️ Receipt parsed successfully
[Purchases] - DEBUG: ℹ️ PostReceiptDataOperation: Posting receipt (note: the contents might not be up-to-date, but it will be refreshed with Apple's servers):
{"opaque_value":"pCYb8zO+pl6OgoobmBlyaA==","original_application_version":"1.0","bundle_id":"ch.promptly.promptly","sha1_hash":"zHRryx2E\/eFIIUUGOqnkefvR8bw=","application_version":"48","creation_date":"2023-07-21T05:56:39Z","in_app_purchases":[{"product_id":"rc_premium_monthly","quantity":1,"transaction_id":"2000000373185658","is_in_trial_period":false,"is_in_intro_offer_period":false,"expires_date":"2023-07-21T06:01:30Z","web_order_line_item_id":2000000032360253,"original_purchase_date":"2023-07-21T05:56:38Z","original_transaction_id":"2000000373185658","product_type":3,"purchase_date":"2023-07-21T05:56:30Z"}]}
[Purchases] - DEBUG: ℹ️ There are no requests currently running, starting request POST receipts
[Purchases] - DEBUG: ℹ️ API request started: POST /v1/receipts
[Purchases] - DEBUG: ℹ️ API request completed: POST /v1/receipts (200)
[Purchases] - DEBUG: ℹ️ PostReceiptDataOperation: Finished
[Purchases] - INFO: 💰 Finishing transaction '2000000373185658' for product 'rc_premium_monthly'
[Purchases] - DEBUG: ℹ️ Serial request done: POST receipts, 0 requests left in the queue
Even if the purchase says completed, the await never completes
Can you send us the complete logs, including from SDK initialization? Also, any chance you have any other StoreKit SDK in your app? (Example: https://github.com/RevenueCat/purchases-ios/issues/2415#issuecomment-1579324706)
static configureSDK() async {
if (Platform.isIOS || Platform.isMacOS) {
StoreConfig(
store: Store.appStore,
apiKey: Constants.appleApiKey,
);
}
await Purchases.setLogLevel(LogLevel.debug);
PurchasesConfiguration configuration;
if (StoreConfig.isForAmazonAppstore()) {
configuration = AmazonConfiguration(StoreConfig.instance.apiKey)
..appUserID = null
..observerMode = false;
} else {
configuration = PurchasesConfiguration(StoreConfig.instance.apiKey)
..appUserID = null
..observerMode = false;
}
await Purchases.configure(configuration);
}
I also have in_app_purchase
Do you mind filing a separate issue for that so we can keep this about slow StoreKit calls?
Sure @NachoSoto. I dont think it is slow, it never seems to be complete. I waited for 25 mins.
Yup, seems like a separare issue.
https://github.com/RevenueCat/purchases-flutter/issues/768
@NachoSoto I think this might be related since the issues discussed in the thread here is exactly what we are facing
Hello, I have the same issue only on IOS.
I use React native SDK.
The paiement popup are opening in less than 1 second on android but on IOS it's take 8 seconds !
I want to release my app but I can't do it with this delay.
Do you have idea ?
This is a known iOS issue, especially on sandbox. We've filed a bug with Apple but have not heard back yet: FB12402539
I recommend filing more feedbacks directly with Apple. The more duplicate they get, the higher the chances they'll address it.
This is a known iOS issue, especially on sandbox. We've filed a bug with Apple but have not heard back yet: FB12402539
I recommend filing more feedbacks directly with Apple. The more duplicate they get, the higher the chances they'll address it.
I just sent the version on Testflight and the delay is always so long!
I'm going to send to production like this, hope I don't lose too many customers :/