Apple includes all non-consumable purchases and the entire renewal history of subscription purchases in the receipt. This means receipts for some users are very large (100KB+) if they have purchased a lot of non-consumables and subscriptions.
When a user with a large receipt restores purchases, they will receive a processPurchase call for every purchase. This can total 1000+ calls. Unity will provide the receipt in every processPurchase call, including a 100KB+ string. This string contains the entire receipt payload but is subtly different for each processPurchase call, since it contains the TransactionID of the purchase. This means Unity will allocate 1000+ 100KB+ strings, totaling 100MB+. This will cause a heavy lag spike and may crash the app.
Our app is not live yet. However, after preliminary testing in the sandbox, we foresee this as being a major issue. Our app has many small subscription products available to purchase and it will not be uncommon for users to have 100’s if not 1000’s of renewals over time. Therefore we expect many of our users will encounter this issue.
I’m happy to provide more information, however the problem boils down to what I described in my original post - essentially duplicating very large receipt strings. On our end, we are already de-duplicating these receipts before sending them to our backend validation service, which mitigates the “n-squared” nature of the problem, at least partially. However, we do not currently have a way of improving this in the app itself, since Unity is allocating these strings.
We would very much like to fix this issue before it becomes a problem. Please let me know how we can help in solving this issue.
Apple sends all the receipts each time, we have no control over this. One user mentioned it appeared to be caused by the use of the CrossPlatformValidator, can you confirm? Can you run a Profiler memory check?
I share the device logs and my script.
Device info:
iPad: iOS13.3.1
I’m sorry I said CrossPlatformValidator is crash my app and it was different.
One of the device no longer causes the memory rising by deleting CrossPlatformValidatior, but not for all device.
I tested with IAP 1.23.1.
I share the test log. I didn’t edit my code I shared before.
The repeated log "Promo available for " is still shown.
UnityIAP: Promo interface is available for 42 items
UnityEngine.Purchasing.Promo:ProvideProductsToAds(HashSet`1)
UnityEngine.Purchasing.JSONStore:OnPurchaseSucceeded(String, String, String)
UnityEngine.Purchasing.Extension.UnityUtil:Update()
Umm,
I had the problem of extremely high memory usage and app crashing, but this no longer seems to be reproduced with my device.
current memory rising graph
A few of my user claim they are still in this crash problem.(1.22.0)
I will update Unity IAP and see how it goes.