SKProductsRequest fails with SKErrorDomain error 0

I have an app with in-app purchases, where a small number of users report they are unable to download previously purchased iap's.


It looks like the app is unable to communicate with the app store, but there definitely have a working internet connection. Logs returned from these users show that SKProductsRequest is failing with

error.localizedDescription = The operation couldn’t be completed. (SKErrorDomain error 0.)

error.code = 0

error.domain = SKErrorDomain


Have tried getting users to reboot all the hardware at the their location, re-installing the app, signing out of iTunes. The problem is persistent for these users.


Anyone seen this? Any ideas?

We've seen this issue with a handful of our users, and I was finally able to replicate it today. After gathering logs from one of our users, we noticed that their device was low on disk space. So, I filled up one of my test devices with video, then launched our app, and voilà: it was unable to obtain product IDs, and attempting to restore purchases produced the SKErrorDomain error 0. The device's log was full of crash logs like this:


Aug 23 15:22:11 iPhone-5 itunesstored[823] <Error>: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFData objectForKey:]: unrecognized selector sent to instance 0x17b83200'
...
Aug 23 15:22:11 iPhone-5 com.apple.xpc.launchd[1] (com.apple.itunesstored[823]) <Notice>: Service exited due to signal: Abort trap: 6
Aug 23 15:22:11 iPhone-5 ReportCrash[817] <Error>: Not saving crash log because we have reached the limit for logs to store on disk.  Sync or otherwise clear logs from /var/mobile/Library/Logs/CrashReporter to save new logs.
...
Aug 23 15:22:11 iPhone-5 ReportCrash[817] <Error>: Thread 1 name:  Dispatch queue: com.apple.itunesstored.StoreKitClient.0x16eaa170
Aug 23 15:22:11 iPhone-5 ReportCrash[817] <Error>: Thread 1 Crashed


Now that it's in this state, I can't get the issue to go away: I freed up 3 GB of space, restarted the device, and even reinstalled the app, but to no avail. I plan to file a bug report, but will continue to look for a workaround.


For the others who are experiencing this issue: are you hosting downloadable IAP content with Apple?

Great info giilby. I'll try filling up a test device too, and report back.


In my case, yes, most of our IAPs are downloadable, hosted by Apple.


Update:


I filled up a device to the point where I was getting failed write attempts when I tried to write files to disk (using a separate test app). I then tried an IAP purchase in an App Store version of my app. I couldn't replicate the error, everything worked fine (other than the download failing because of low disk space - but that's an expected error). The device is on iOS 8.4.1.


*sigh* I was hoping to get closer to an answer. I have about 20 users now who can't restore purchases and can't buy new purchases.

This a bug report situation. If you or your users encounter this situation, please file a bug report - <https://bugreport.apple.com>. If you submit the bug report, please let me know, and I'll forward the number to the StoreKit engineer. As to a possible workaround, I can only think of one that means to stop making use of the Apple Hosted content, but then the responsibility for preflighting disk space and downloading content, falls to the app which means added complexity to the app.


rich kubota - rkubota@apple.com

developer technical support CoreOS/Hardware/MFI

Rich,


I filed a bug report (22396009) yesterday. Thanks for your help!

pinch, it's a bummer that you couldn't replicate this issue. I'm going to restore my device to a) see if it's a (terrible) workaround to getting IAPs working again, and b) see if I can replicate the issue a second time. I definitely haven't ruled out my code as being part of the problem, but still, the possibility for itunesstored to enter such an unrecoverable state for a particular app does seem like a bug in StoreKit.

Pinch,


Just wanted to shed some additional light on this issue. I think I've narrowed down the exact point in my code that initiates this problem:


- (void)paymentQueue:(SKPaymentQueue *)queue updatedDownloads:(NSArray *)downloads {
    for (SKDownload *download in downloads) {
        switch (download.downloadState) {
            case SKDownloadStateFailed:
                ...
                break;


When handling a failed download, I should be finishing the related transaction, but I'm not. If the user doesn't attempt any other transactions after the failure, quits the app, and re-opens it, the itunesstored crashes begin when SKPaymentQueue's addTransactionObserver is invoked.


I updated my code to finish the transaction when a download fails, and have verified that it prevents the itunesstored crashes from occurring.


Notably, restoring a backup taken before the itunesstored crashes start to occur will get rid of them. That makes me think that some app-specific record in the Apple-managed payment queue database is entering an unexpected state when a transaction isn't finished after a download failure.

Giilby,


Ah, that makes perfect sense. Perhaps the download fails in some cases when there's not enough space, falls into the SKDownloadStateFailed case, and the transaction doesn't get finished.


I took a look at my paymentQueue:updateDownloads method and verifiied that I am finishing the transaction in SKDownloadStateFailed, as well as SKDownloadStateFinished and SKDownloadStateCancelled. The only way I could see that being bypassed is if the app were to crash before reaching that line.


I hope your fix clears things up for you. I'll keep looking, maybe I'll find some case I'm not finishing the transaction.

giilby,


Was there ever any action taken on your bug report? Did the fix you made in your code seem to clear things up for your users?


I did find a *real* edge case path in my code where it was possible the an IAP might not be "finished". But I haven't pushed that change out yet and was curious if you've had any luck.


Either way, an unfinished IAP shouldn't send the app into a state where all IAPs are broken, so I hope the issue will be fixed.

Rich,


I was finally able to collect some itunesstored crashlogs from users and filed a bug report (22917074).

Hello Pinch


Did you get some infos back ?

It seems we have the same problem since iOS 8.3 mid-march.


Thanks,

Julien

Hi CoachGuitar


No I haven't hear anything new on this.


I've been dealing with the issue for months now. It seems to be escalating lately as people get new phones, try to restore purchases, and for some of them something goes wrong, crashes itunesstored, and they're stuck, unable to restore or purchase anything in the app indefinitely. It's as if the user's purchase data for my app gets corrupted.


As I mentioned above I filed a bug report yesterday, as I was able to get some itunesstored crash logs from users. I've been attaching more logs to the bug report as they come in. The all appear to the same crash as far as I can tell. I'll report back here If I hear anything.


To get the crash logs I've asked users to check in Settings > Privacy > Diagnostics & Usage > Diagnostic & Usage Data and search for anything that starts with "itunesstored_" then copy the content and send it to me by email.

Interesting. Could you share with us the crash report ? I will check them and i will share any things I can find with you here ok ?

Thanks a lot, and i hope your bug report will be addressed soon

jadeware[at]gmail[dot]com

pinch,


My bug report (22396009) was marked as a duplicate of 21857515 and was closed, so unfortunately, I haven't received any status updates. My fix (which I released a week before iOS 9 came out) does seem to prevent new users from encountering the issue, but anyone who had already experienced the issue with a previous version is still unable to purchase, download, or restore any IAPs in our app :-(. It's very frustrating for those users because all the "fixes" that folks usually try (e.g. restarting the phone, deleting/reinstalling the app, upgrading to iOS 9.0.x, etc) don't work.

pinch,


Our experience is pretty much the same as yours: it seems like recently, we've been receiving more reports of this bug. I'm operating under the assumption that they're users who either a) haven't updated to the latest version of our app or b) encountered the issue before upgrading to the latest version, but maybe there are more code paths that corrupt the purchase data for our apps.

I was able to reproduce this bug on my own device (running on 7.1.2). This occurs when the device is lacking free space. If you don't finish the transaction the download process loops (downloads to 97% then skips to 80% and the issue repeats). Even if you clear some space on the device it doesn't help. In crashreport (itunesstiored) (something goes wrong with unzipping package):

Thread 2 Crashed:

0 Bom 0x0000000191f9d004 BOMPKZipReadNextSignature + 372

1 Bom 0x0000000191f8935c _copyFromPKZip + 164

2 Bom 0x0000000191f87164 BOMCopierCopyWithOptions + 5012

3 itunesstored 0x00000001000fc398 0x1000c0000 + 246680

4 itunesstored 0x00000001000fbb0c 0x1000c0000 + 244492

5 iTunesStore 0x00000001987eb8f4 -[ISOperation _main:] + 304)

SKProductsRequest fails with SKErrorDomain error 0
 
 
Q