Titanium JIRA Archive
Appcelerator Modules (MOD)

[MOD-2399] Ti.StoreKit: App crash during restore in app purchases

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2018-06-20T08:32:08.000+0000
Affected Version/sTi.StoreKit 4.3.0
Fix Version/sTi.StoreKit 4.3.2
ComponentsStoreKit
Labelscrash, production, storekit
ReporterLorenzo Piccinini
AssigneeHans Knöchel
Created2018-02-20T15:05:18.000+0000
Updated2018-08-06T17:49:31.000+0000

Description

What about I'm writing it's a very strange thing. I released an update of my app with in app purchase . One user with iPhone X reported me that trying to +restore+ in app purchases the app goes in crash. I tried with my iPhone 6s and other 6s and 5c without problems. When my brother tried on its iPhone 5s the app is crashed. He has tried with wife's iPhone 5s... same crash. Finally I tried with my father's iPhone 5s.... the same thing... app is crashed. I tried to run app in development mode on the iPhone 5s to see the debug and understand the problem. App doesn't crash but get error: [ERROR] : Failed to restore all completed transactions: Error Domain=SKErrorDomain Code=0 "Impossibile connettersi a iTunes Store" UserInfo={NSLocalizedDescription=Impossibile connettersi a iTunes Store} How can I debug this problem? Any ideas? It's first time that I have a no replicable production problem.

Comments

  1. Hans Knöchel 2018-02-21

    Hey there! That error sounds like an iTunes server issue. There are some native threads about this issue as well, so you might want to contact Apple to check the status. If it still persists now, please let us know and provide a test case, we will validate it then. Thanks!
  2. Lorenzo Piccinini 2018-02-21

    Hello, the error I think is not the real cause, with the sandbox is very frequent and in that case app isn’ crashed. The real problem is the app crashed by storekit in production (testflight too) ever with iPhone 5s and iPhone X . I’m not able to reproduce it with iPhone 5c and iPhone 6s in production and development too. I’m in difficulty to debug it. Can I debug production app?
  3. Hans Knöchel 2018-02-21

    There must be something wrong with your configuration. The functionality is used in many production apps without issues. You can see the symbolicated crash log in iTunes connect if you checked that option (include dSYM) during app upload. If you have that, you can upload it here and we can take a look again. For now, we need a test case in order to reproduce it.
  4. Lorenzo Piccinini 2018-02-21

    Ok, I found the log. In Xcode red line on point 5. Last Exception Backtrace: 0 CoreFoundation 0x18179f164 __exceptionPreprocess + 124 (NSException.m:166) 1 libobjc.A.dylib 0x1809e8528 objc_exception_throw + 56 (objc-exception.mm:521) 2 CoreFoundation 0x181737c9c _CFThrowFormattedException + 112 (CFObject.m:1937) 3 CoreFoundation 0x18166ffd0 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 352 (NSPlaceholderDictionary.m:0) 4 CoreFoundation 0x18166fe4c +[NSDictionary dictionaryWithObjects:forKeys:count:] + 64 (NSDictionary.m:622) 5 "NAME APP" 0x1008c51c4 -[TiStorekitModule paymentQueueRestoreCompletedTransactionsFinished:] + 120 (TiStoreKitModule.m:582) 6 CoreFoundation 0x1816645a0 CFArrayApplyFunction + 80 (CFArray.c:684) 7 StoreKit 0x194cfea38 -[SKPaymentQueue _notifyObserversRestoreTransactionsFinished] + 136 (SKPaymentQueue.m:567) 8 StoreKit 0x194cfe328 __44-[SKPaymentQueue _handleMessage:connection:]_block_invoke + 168 (SKPaymentQueue.m:0) 9 libdispatch.dylib 0x18111ea54 _dispatch_call_block_and_release + 24 (init.c:994) 10 libdispatch.dylib 0x18111ea14 _dispatch_client_callout + 16 (object.m:502) 11 libdispatch.dylib 0x18112b698 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1016 (inline_internal.h:2500) 12 CoreFoundation 0x181747344 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 (CFRunLoop.c:1815) 13 CoreFoundation 0x181744f20 __CFRunLoopRun + 2012 (CFRunLoop.c:3111) 14 CoreFoundation 0x181664c58 CFRunLoopRunSpecific + 436 (CFRunLoop.c:3245) 15 GraphicsServices 0x183510f84 GSEventRunModal + 100 (GSEvent.c:2245) 16 UIKit 0x18adbd5c4 UIApplicationMain + 236 (UIApplication.m:3956) 17 "NAME APP" 0x100635114 main + 84 (main.m:30) 18 libdyld.dylib 0x18118456c start + 4
  5. Lorenzo Piccinini 2018-02-21

    Hey there! I have important news: I done rollback to ti.storekit 4.1.1 and its seems there are no more crashes during in app purchases restoring!
  6. Hans Knöchel 2018-02-26

    Hey [~otto.pic], good catch! Although I am happy it works, of course it should work for all future versions as well. Would you mind trying [this binary](https://www.dropbox.com/s/2z223h95g5yishe/ti.storekit-iphone-4.3.1.zip?dl=0) (v4.3.1) which addresses a few possible issues regarding null-values. If it works, we will release a new version immediately. Thanks for testing!
  7. Lorenzo Piccinini 2018-02-26

    Thank you Hans !! I downloaded it and I will do tests asap. I'll update you about results.
  8. Hans Knöchel 2018-02-26

    Btw, there is also a new [iOS 11.3 API](https://developer.apple.com/documentation/storekit/skadnetwork/2943654-registerappforadnetworkattributi?language=objc) we could include. So if it works, we can include that one as well!
  9. Lorenzo Piccinini 2018-02-26

    I tested new lib distributing the app by testflight, unfortunately app crash again during restore.
  10. Lorenzo Piccinini 2018-03-01

    Good morning @Hans, have you seen my last reply about test of Ti.StoreKit 4.3.1 ?
  11. Hans Knöchel 2018-03-28

    Hey there! Jumping back on this one now. Can you get a crash log? The (localized) error is not the best for debugging in this case. Also, does the crash happen when calling restoreCompletedTransactions or a different method? And does it crash when calling it or when the purchase restore is performed internally (a few seconds later)?
  12. Lorenzo Piccinini 2018-03-28

    App crash like first time have reported during restoring. From crashlog report: 5 NAME APP 0x1011491a4 -[TiStorekitModule paymentQueueRestoreCompletedTransactionsFinished:] + 2707876 (TiStoreKitModule.m:582) I'm not able to test on my device, from log I'm not understand if crash during call or not, but if I remember well, products wasn't restored after relaunch of the app.
  13. Hans Knöchel 2018-03-28

    I think I finally found the issue. It was a one-liner typo during the refactoring of the module. Please try [this module](https://www.dropbox.com/s/9nj3hpzcy2xxxik/ti.storekit-iphone-4.3.2.zip?dl=0) and remember to set the version="4.3.2" attribute in the <module>, so it actually uses the version.
  14. Hans Knöchel 2018-03-28

    PR: https://github.com/appcelerator-modules/ti.storekit/pull/34
  15. Hans Knöchel 2018-03-29

    [~otto.pic] Can you please try it out?
  16. Lorenzo Piccinini 2018-03-29

    I tried it, I'm sorry but it crash again. Xcode crash report show me the same error. I'm sorry if I'm not enough helpful. Last Exception Backtrace: 0 CoreFoundation 0x18690f164 __exceptionPreprocess + 124 (NSException.m:166) 1 libobjc.A.dylib 0x185b58528 objc_exception_throw + 56 (objc-exception.mm:521) 2 CoreFoundation 0x1868a7c9c _CFThrowFormattedException + 112 (CFObject.m:1937) 3 CoreFoundation 0x1867dffd0 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 352 (NSPlaceholderDictionary.m:0) 4 CoreFoundation 0x1867dfe4c +[NSDictionary dictionaryWithObjects:forKeys:count:] + 64 (NSDictionary.m:622) 5 [APP NAME] 0x1005c4d14 -[TiStorekitModule paymentQueueRestoreCompletedTransactionsFinished:] + 120 (TiStoreKitModule.m:582) 6 CoreFoundation 0x1867d45a0 CFArrayApplyFunction + 80 (CFArray.c:684) 7 StoreKit 0x199e6ea38 -[SKPaymentQueue _notifyObserversRestoreTransactionsFinished] + 136 (SKPaymentQueue.m:567) 8 StoreKit 0x199e6e328 __44-[SKPaymentQueue _handleMessage:connection:]_block_invoke + 168 (SKPaymentQueue.m:0) 9 libdispatch.dylib 0x18628ea54 _dispatch_call_block_and_release + 24 (init.c:994) 10 libdispatch.dylib 0x18628ea14 _dispatch_client_callout + 16 (object.m:502) 11 libdispatch.dylib 0x18629b698 _dispatch_main_queue_callback_4CF$VARIANT$mp + 1016 (inline_internal.h:2500) 12 CoreFoundation 0x1868b7344 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12 (CFRunLoop.c:1815) 13 CoreFoundation 0x1868b4f20 __CFRunLoopRun + 2012 (CFRunLoop.c:3111) 14 CoreFoundation 0x1867d4c58 CFRunLoopRunSpecific + 436 (CFRunLoop.c:3245) 15 GraphicsServices 0x188680f84 GSEventRunModal + 100 (GSEvent.c:2245) 16 UIKit 0x18ff2d5c4 UIApplicationMain + 236 (UIApplication.m:3956) 17 [APP NAME] 0x1003358fc main + 84 (main.m:30) 18 libdyld.dylib 0x1862f456c start + 4
  17. richard@gorbutt.com 2018-03-30

    4.3.2 is behaving on my iPhone 7+ iOS 11.3.2 with this build. However I think because I already have the receipt from a test purchase using 4.1.1 it may be OK. To test that I re-ran the app with 4.3.0 and it worked the same. Not sure I can get rid of the receipt. So, for me, it's not conclusive.
  18. Lorenzo Piccinini 2018-03-30

    How reported in the first comment on every iPhone 5s app crash 100% with or without receipt of previous storekit version.. With other devices is different.On my iPhone 6s doesn’t crash, but on iPhone 6s of my friend is crashed and production user reported me the same thing with a iPhone X. Rolling back to 4.1.1 no more issues from any devices. It seems a memory problem or something like this. If you have a iphone 5S too I can send you invitation to test my app.
  19. Hans Knöchel 2018-06-20

    I *finally* figured out the real error. It was the shorthand NSDictionary usage:
        // CRASH!
        NSDictionary *event = @{ @"transactions" : _restoredTransactions };
        
        // NO CRASH
        NSDictionary *event = [NSDictionary dictionaryWithObjectsAndKeys:_restoredTransactions, @"transactions", nil];
        
    I fixed it by guarding the _restoredTransactions against nil and it works just fine again. New release: https://github.com/appcelerator-modules/ti.storekit/releases/tag/v4.3.2
  20. Lorenzo Piccinini 2018-06-20

    Great work! I'll test it again. Thank you so much!
  21. Lorenzo Piccinini 2018-06-25

    It seems it's works fine.
  22. Eric Merriman 2018-08-06

    Cleaning up older fixed issues. If this issue should not have been closed as fixed, please reopen.

JSON Source