• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by JHSV · Jun 06, 2014 at 08:49 AM · iosprime31in-app-purchasesandboxstorekit

With Unity iOS Prime31 StoreKit plugin (3/14/14), sandbox, restoreCompletedTransactions() loops over stuck transactions n^2 times

Our app is developed in Unity and built to iOS and Android. For iOS in-app purchases, we are using the Prime31 StoreKit plugin. We now use the 5/24/14 version of the plugin, but the issue was first noticed when we upgraded to the 3/14/14 version.

The behavior occurs when performing certain actions such as restoreCompletedTransactions(). It will first say "paymentQueueRestoreCompletedTransactionsFinished" and display information about the purchase including its transactionState.

 paymentQueueRestoreCompletedTransactionsFinished
 transactionUpdatedEvent: <StoreKitTransaction> ID: test_monthly, quantity: 1, transactionIdentifier: 1000000113168263, transactionState: Restored

 productPurchaseAwaitingConfirmationEvent: <StoreKitTransaction> ID: test_monthly, quantity: 1, transactionIdentifier: 1000000113168263, transactionState: Restored

Then it attempts to finish all pending transactions. If there are any stuck transactions (http://stackoverflow.com/questions/3139280/transaction-comes-back-after-finishtransaction-has-been-called-on-it), the console will report that it is telling the transactions to finalize, but will say that 0 have updated, except the first time, which will say all of them have updated:

 transactions that have been updated by the payment queue: 0
 transactions that are currently in the payment queue (and possibly stuck there): 59
 finishing transaction: 1000000113168314 : test_monthly
 StoreKit: transaction completed: <SKPaymentTransaction: 0x190d49f0>
 finalizing and asking the payment queue to finish transaction: <SKPaymentTransaction: 0x190d49f0>
 finishing transaction: 1000000113168318 : test_monthly
 ....

For each of the 59 transactions, it will display those three lines ("finishing transaction", "transaction completed", "finalizing..."), and once it has gone through all 59 of them, it will repeat the entire block, from "productPurchaseAwaitingConfirmationEvent" (with a different transaction id) down to the last "finalizing" of the 59th transaction, for 59 times total. As a result, if there are n transactions, it will create n^2 log messages. When I pressed other buttons in that scene, such as "Get Saved Transactions" and "Finish All Pending Transactions", it told me that there are 0 transactions to be saved or finished.

Afterwards, if it loops over all of the transactions enough times, it updates all of the transactions as restored, printing these lines out n^2 times:

 purchaseSuccessfulEvent: <StoreKitTransaction> ID: test_monthly, quantity: 1, transactionIdentifier: 1000000113168959, transactionState: Restored
 ....

Finally, it will remove each transaction from the paymentQueue, printing these lines only n times (but will re-add them the next time you restore):

 paymentQueue:removedTransaction: <SKPaymentTransaction: 0x1961d070>
 ...

Here are the problems with this behavior:

  1. It takes a long time to cycle through these transactions, and the app is hung while this is happening.

  2. If n is sufficiently large (roughly more than 25 transactions), the app runs out of memory and crashes once it loops through enough times. It crashes during the section when it is looping over the transactions stuck in the payment queue.

  3. Each test account has a finite lifespan now. Numerous transactions may get stuck each time the account is used, and eventually the account may become unusable because store actions that loop through the stuck transactions will always crash if n is sufficiently large.

The behavior happens within the Prime31 plugin code, and is reproducible in the demo scene provided with the plugin.

  1. Create a new project and import the Prime31 StoreKit plugin package.

  2. Put the names of your products under the "Request Product Data" button section in StoreKitGUIManager.cs.

  3. Create a sandbox store and fill it with products (we have a non-consumable and a monthly subscription with a one-week free trial).

  4. Set the bundle id of the project to match the bundle id for your sandbox.

  5. Set the version number of the project to a high number (In our case, it's about 1200 or higher. I am not sure why, but I noticed that it loops over many more transactions if the version number is set at 1200 or above (dangerous, may crash) and loops for a much smaller number for versions below 1200 (safer). I think it coincides with the version in which we started to use free trials.)

  6. Build to iOS.

  7. Create a test user and have it perform many transactions with your store, which should accumulate some stuck transactions in the payment queue.

  8. Click on the restore button and enter the login and password of that test account and watch the console.

Here are my questions:

  1. Does this behavior only occur in sandbox, or can it occur in live production as well? Either way, how can we verify that it won't happen in live production or that any fix we may do will not break live production?

  2. How can we fix this problem or create a workaround that will allow us to restore transactions or other functions properly without experiencing the issue?

  3. If we can do (2), can we use the app and restore functionality with old accounts, or would we no longer be able to use them and must create new accounts that have not had any transactions before?

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Luke Lamothe · Apr 11, 2016 at 11:11 AM 0
Share

We are also running into this. Does anyone know if there is a fix or workaround available?

avatar image rnickerson · Aug 25, 2016 at 06:30 PM 0
Share

We're seeing the EXACT behavior with our app's transactions as well. Crashes the app on older devices due to memory pressure.

avatar image SweatyChair · Jun 30, 2017 at 10:01 AM 0
Share

An old post but I run into the same problem, anyone?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by SweatyChair · Jul 01, 2017 at 03:42 AM

It's a bug in 2.16, should already fixed in 2.17 (and you should keep the latest version anyway)

  • bug fix: avoid restoring the same transactions multiple times even if Apple sends them over and over again

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

24 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Storekit Product details stopped showing ? 0 Answers

Prime31 Storekit purchaseSuccessfulEvent claims to have receipt, but I can't find it. How do I find the receipt? 1 Answer

iOS Storekit stuck on "Purchasing" (Prime31) 0 Answers

Blackish GUIKit001 + Prime31 StoreKit for In-App-Purchase 1 Answer

How to bind Prime31 ios storekit plugin with GUIText elements? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges