我的遊戲是免費下載,並有一個IAP解鎖完整的遊戲。它被購買後立即崩潰了少數用戶和墜毀是由我的函數的開頭添加兩行固定:In App Purchase的錯誤已經得到解決,但仍然會崩潰,先前受影響的用戶
let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(0.1 * Double(NSEC_PER_SEC)))
dispatch_after(delayTime, dispatch_get_main_queue()) {
*my original code*
}
這裏是它得到了解決螺紋:In App Purchase causes occasional crash
但儘管該問題不再出現新的用戶,應用程序仍然崩潰了誰最初是受了錯誤的人,他們更新到固定的版本甚至後。我假設有一個腐敗的環境某處從最初的崩潰在他們的設備上,因爲我誰下載了遊戲他另一個設備上的一個用戶,他能夠恢復IAP和玩遊戲就好了。
這裏是一個崩潰報告:
Incident Identifier: B7B61633-1BE4-4AB2-99ED-A207B2E88525
CrashReporter Key: 2b01761b32c1d23c1adf755f83cc58464c9e7e77
Hardware Model: iPhone5,2
Process: MyApp [551]
Path: /private/var/mobile/Containers/Bundle/Application/43D176E1-395E-4BF5-A0D5-3602068AADA6/MyApp.app/MyApp
Identifier: com.MyName.MyApp
Version: 5 (1.1)
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2016-03-02 02:10:42.42 +0000
Launch Time: 2016-03-02 02:10:27.27 +0000
OS Version: iOS 9.2.1 (13D15)
Report Version: 105
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000000e7ffdefe
Triggered by Thread: 0
Breadcrumb Trail: (reverse chronological seconds)
14 GC Framework: startAuthenticationForExistingPrimaryPlayer
Global Trace Buffer (reverse chronological seconds):
13.238455 CFNetwork 0x0000000023da3e45 TCP Conn 0x16ede9d0 SSL Handshake DONE
13.532519 CFNetwork 0x0000000023da3d7f TCP Conn 0x16ede9d0 starting SSL negotiation
13.534444 CFNetwork 0x0000000023e231a5 TCP Conn 0x16ede9d0 complete. fd: 11, err: 0
13.537454 CFNetwork 0x0000000023e242a7 TCP Conn 0x16ede9d0 event 1. err: 0
13.CFNetwork 0x0000000023e24325 TCP Conn 0x16ede9d0 started
13.648224 CFNetwork 0x0000000023da3e45 TCP Conn 0x16ed89f0 SSL Handshake DONE
13.982238 CFNetwork 0x0000000023da3d7f TCP Conn 0x16ed89f0 starting SSL negotiation
13.982896 CFNetwork 0x0000000023e231a5 TCP Conn 0x16ed89f0 complete. fd: 6, err: 0
13.984447 CFNetwork 0x0000000023e242a7 TCP Conn 0x16ed89f0 event 1. err: 0
Thread 0 name:
Thread 0 Crashed:
0 MyApp 0x002028ac _TFFC11MyApp9IAPHelper12paymentQueueFS0_FTCSo14SKPaymentQueue19updatedTransactionsGSaCSo20SKPaymentTransaction__T_U_FT_T_ + 7504 (IAPHelper.swift:0)
1 libdispatch.dylib 0x23447dd6 _dispatch_call_block_and_release + 10 (init.c:760)
2 libdispatch.dylib 0x234514e6 _dispatch_after_timer_callback + 66 (queue.c:3293)
3 libdispatch.dylib 0x23447dc2 _dispatch_client_callout + 22 (init.c:819)
4 libdispatch.dylib 0x2345a6d2 _dispatch_source_latch_and_call + 2042 (inline_internal.h:1063)
5 libdispatch.dylib 0x23449d16 _dispatch_source_invoke + 738 (source.c:755)
6 libdispatch.dylib 0x2344c1fe _dispatch_main_queue_callback_4CF + 394 (inline_internal.h:1043)
7 CoreFoundation 0x2386cfc4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8 (CFRunLoop.c:1613)
8 CoreFoundation 0x2386b4be __CFRunLoopRun + 1590 (CFRunLoop.c:2718)
9 CoreFoundation 0x237bdbb8 CFRunLoopRunSpecific + 516 (CFRunLoop.c:2814)
10 CoreFoundation 0x237bd9ac CFRunLoopRunInMode + 108 (CFRunLoop.c:2844)
11 GraphicsServices 0x24a37af8 GSEventRunModal + 160 (GSEvent.c:2245)
12 UIKit 0x27aa9fb4 UIApplicationMain + 144 (UIApplication.m:3681)
13 MyApp 0x001898f4 main + 180 (AppDelegate.swift:12)
14 libdyld.dylib 0x23470872 start + 2 (start_glue.s:64)
Thread 1 name:
Thread 1:
0 libsystem_kernel.dylib 0x23543320 kevent_qos + 24
1 libdispatch.dylib 0x2345794e _dispatch_mgr_invoke + 254 (source.c:2542)
2 libdispatch.dylib 0x23449a2e _dispatch_mgr_thread + 38 (source.c:2573)
Thread 2:
0 libsystem_kernel.dylib 0x2354288c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x235e0e18 _pthread_wqthread + 1036 (pthread.c:1999)
2 libsystem_pthread.dylib 0x235e09fc start_wqthread + 8 (pthread_asm.s:147)
Thread 3:
0 libsystem_kernel.dylib 0x2354288c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x235e0e18 _pthread_wqthread + 1036 (pthread.c:1999)
2 libsystem_pthread.dylib 0x235e09fc start_wqthread + 8 (pthread_asm.s:147)
Thread 4:
0 libsystem_kernel.dylib 0x2354288c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x235e0e18 _pthread_wqthread + 1036 (pthread.c:1999)
2 libsystem_pthread.dylib 0x235e09fc start_wqthread + 8 (pthread_asm.s:147)
Thread 5 name:
Thread 5:
0 libsystem_kernel.dylib 0x2352dbf8 mach_msg_trap + 20 (syscall_sw.h:105)
1 libsystem_kernel.dylib 0x2352d9f8 mach_msg + 40 (mach_msg.c:103)
2 CoreFoundation 0x2386cf1c __CFRunLoopServiceMachPort + 136 (CFRunLoop.c:2345)
3 CoreFoundation 0x2386b2a2 __CFRunLoopRun + 1050 (CFRunLoop.c:2607)
4 CoreFoundation 0x237bdbb8 CFRunLoopRunSpecific + 516 (CFRunLoop.c:2814)
5 CoreFoundation 0x237bd9ac CFRunLoopRunInMode + 108 (CFRunLoop.c:2844)
6 CFNetwork 0x23e049e6 +[NSURLConnection(Loader) _resourceLoadLoop:] + 486 (NSURLConnection.mm:325)
7 Foundation 0x240c632c __NSThread__start__ + 1144 (NSThread.m:1134)
8 libsystem_pthread.dylib 0x235e2c7e _pthread_body + 138 (pthread.c:656)
9 libsystem_pthread.dylib 0x235e2bf2 _pthread_start + 110 (pthread.c:692)
10 libsystem_pthread.dylib 0x235e0a08 thread_start + 8 (pthread_asm.s:162)
Thread 6 name:
Thread 6:
0 libsystem_kernel.dylib 0x23541f14 __select + 20
1 CoreFoundation 0x238723c0 __CFSocketManager + 572 (CFSocket.c:2128)
2 libsystem_pthread.dylib 0x235e2c7e _pthread_body + 138 (pthread.c:656)
3 libsystem_pthread.dylib 0x235e2bf2 _pthread_start + 110 (pthread.c:692)
4 libsystem_pthread.dylib 0x235e0a08 thread_start + 8 (pthread_asm.s:162)
Thread 7:
0 libsystem_kernel.dylib 0x2354288c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x235e0e18 _pthread_wqthread + 1036 (pthread.c:1999)
2 libsystem_pthread.dylib 0x235e09fc start_wqthread + 8 (pthread_asm.s:147)
Thread 0 crashed with ARM Thread State (32-bit):
r0: 0x00000000 r1: 0x00000000 r2: 0x39c940b0 r3: 0x00000000
r4: 0x00000000 r5: 0x00631376 r6: 0x00000000 r7: 0x0040dcf4
r8: 0x0064e984 r9: 0x00000000 r10: 0x00000001 r11: 0x16d54600
ip: 0xf64d8965 sp: 0x0040db34 lr: 0x002011f0 pc: 0x002028ac
cpsr: 0x60000010
Binary Images:
<not included for reasons of brevity>
這裏是導致飛機失事的原因引用的函數:
extension IAPHelper: SKPaymentTransactionObserver {
public func paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(0.1 * Double(NSEC_PER_SEC)))
dispatch_after(delayTime, dispatch_get_main_queue()) {
for transaction in transactions {
switch (transaction.transactionState) {
case .Purchased:
print("case .Purchased:")
self.completeTransaction(transaction)
break
case .Failed:
print("case .Failed:")
self.failedTransaction(transaction)
break
case .Restored:
print("case .Restored:")
self.restoreTransaction(transaction)
break
case .Deferred:
print("case .Deferred:")
break
case .Purchasing:
print("case .Purchasing:")
break
}
}
}
}
沒有任何人有任何想法如何解決這個問題呢?因爲我無法複製它,也不知道從哪裏開始。他們試圖從設備上刪除應用程序並下載更新後的版本,但這並沒有什麼區別。
編輯:
我想清楚,墜毀的是誰試圖購買IAP在1.0版本的人約10%。現在,當他們嘗試購買版本1.1中的IAP時,它不會爲任何人而崩潰。這個問題是關於那些10%從1.0版本誰仍然無法正常加載遊戲,因爲當SKPayment試圖檢查他們是否先前已經購買了IAP它崩潰每次。
編輯2:
下面是paymentQueue調用的方法:
private func completeTransaction(transaction: SKPaymentTransaction) {
provideContentForProductIdentifier(transaction.payment.productIdentifier)
SKPaymentQueue.defaultQueue().finishTransaction(transaction)
}
private func restoreTransaction(transaction: SKPaymentTransaction) {
let productIdentifier = transaction.originalTransaction!.payment.productIdentifier
provideContentForProductIdentifier(productIdentifier)
SKPaymentQueue.defaultQueue().finishTransaction(transaction)
}
private func failedTransaction(transaction: SKPaymentTransaction) {
NSNotificationCenter.defaultCenter().postNotificationName(IAPHelperStopSpinnerNotification, object: nil)
if transaction.error!.code != SKErrorPaymentCancelled {
NSNotificationCenter.defaultCenter().postNotificationName(IAPHelperTransactionFailedNotification, object: nil)
}
SKPaymentQueue.defaultQueue().finishTransaction(transaction)
}
編輯3:
我剛剛從它的設備進行應用內購買時墜毀用戶接收到崩潰報告,這表明最初的問題確實沒有被修復。 :-(在更新後的版本中,這些崩潰的數量急劇減少,但看起來似乎仍然存在。我將提出一個新的問題,提供更多的細節,因爲這個頁面現在變得有點亂!
您是否試過在完全相同的設備上使用完全相同的操作系統進行重現?你是否嘗試過使用類似Crashlytics的工具,更好的記錄系統,如CocoaLumberjack? – nhgrif
你沒有修復崩潰,你試圖解決它。你調用的方法中的代碼是什麼? – Wain
@nhgrif它已在不同操作系統的許多不同設備上崩潰。我沒有使用過Crashlytics,也沒有聽說過CocoaLumberjack--他們會怎麼幫忙? – Eatton