com.apple.gamed在删除游戏时崩溃



我有一个iOS应用程序,当你试图使用删除GKTurnBasedMatch时,它会一直崩溃

[match removeWithCompletionHandler:^(NSError *error){}];

当调用完成处理程序时,错误为nil,这意味着它成功地删除了匹配项。匹配确实会被删除(它从未重新出现),但与此同时,gamed(苹果编写的与GameCenter服务器通信的后台守护程序)崩溃。

以下是我删除游戏时在控制台中看到的内容:

Jan 19 20:47:22 Ben-L-iPhone gamed[2233] <Error>: *** Terminating app due to uncaught exception 'NSObjectInaccessibleException', reason: 'CoreData could not fulfill a fault for '0xd000000000b4002a <x-coredata://C0390AE6-6CD0-4A7C-B080-B7649175419A/TurnBasedSession/p45>''
*** First throw call stack:
(0x185ce309c 0x191c61d78 0x1859eb7ac 0x1859fc50c 0x1859fc47c 0x185a7475c 0x185a79034 0x185a797f4 0x185a7a474 0x1922303e0 0x192235d88 0x185a6f3e4 0x185a7a104 0x1859fdbd0 0x100099284 0x185a71b6c 0x1922303e0 0x192235f2c 0x185a71d00 0x10009ce08 0x1000ba8a4 0x192230420 0x1922303e0 0x192235930 0x1922303e0 0x1922373fc 0x192237638 0x1923c5918 0x1923c57a8)
Jan 19 20:47:22 Ben-L-iPhone ReportCrash[2509] <Notice>: ReportCrash acting against PID 2233
Jan 19 20:47:22 Ben-L-iPhone ReportCrash[2509] <Notice>: Formulating crash report for process gamed[2233]
Jan 19 20:47:22 Ben-L-iPhone com.apple.launchd[1] (com.apple.gamed[2233]) <Warning>: (com.apple.gamed) Job appears to have crashed: Abort trap: 6
Jan 19 20:47:22 Ben-L-iPhone ReportCrash[2509] <Notice>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/gamed_2014-01-19-204722_Ben-L-iPhone.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0

有什么想法可以引发这种情况吗?我搜索了苹果开发者论坛和谷歌,但没有找到有类似问题的人。

记录的碰撞报告

Incident Identifier: C201F189-7311-49E5-96F4-890A65FAA19A
CrashReporter Key:   0b745533f4a51b30bf9654557be6c063d06f1ccc
Hardware Model:      iPhone6,1
Process:             gamed [2233]
Path:                /usr/libexec/gamed
Identifier:          gamed
Version:             ???
Code Type:           ARM-64 (Native)
Parent Process:      launchd [1]
Date/Time:           2014-01-19 20:47:22.522 -0600
OS Version:          iOS 7.0.4 (11B554a)
Report Version:      104
Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread:  11
Last Exception Backtrace:
0   CoreFoundation                  0x185ce309c __exceptionPreprocess + 132
1   libobjc.A.dylib                 0x191c61d78 objc_exception_throw + 60
2   CoreData                        0x1859eb7ac _PFFaultHandlerLookupRow + 1900
3   CoreData                        0x1859fc50c -[NSManagedObject(_NSInternalMethods) _newPropertiesForRetainedTypes:andCopiedTypes:preserveFaults:] + 108
4   CoreData                        0x1859fc47c -[NSManagedObject(_NSInternalMethods) _newAllPropertiesWithRelationshipFaultsIntact__] + 108
5   CoreData                        0x185a7475c -[NSManagedObjectContext(_NSInternalAdditions) _committedSnapshotForObject:] + 72
6   CoreData                        0x185a79034 -[NSManagedObjectContext(_NestedContextSupport) _copyChildObject:toParentObject:fromChildContext:] + 144
7   CoreData                        0x185a797f4 -[NSManagedObjectContext(_NestedContextSupport) _parentProcessSaveRequest:inContext:error:] + 1092
8   CoreData                        0x185a7a474 __82-[NSManagedObjectContext(_NestedContextSupport) executeRequest:withContext:error:]_block_invoke + 660
9   libdispatch.dylib               0x1922303e0 _dispatch_client_callout + 16
10  libdispatch.dylib               0x192235d88 _dispatch_barrier_sync_f_slow + 352
11  CoreData                        0x185a6f3e4 _perform + 124
12  CoreData                        0x185a7a104 -[NSManagedObjectContext(_NestedContextSupport) executeRequest:withContext:error:] + 184
13  CoreData                        0x1859fdbd0 -[NSManagedObjectContext save:] + 840
14  gamed                           0x100099284 0x100048000 + 332420
15  CoreData                        0x185a71b6c developerSubmittedBlockToNSManagedObjectContextPerform + 100
16  libdispatch.dylib               0x1922303e0 _dispatch_client_callout + 16
17  libdispatch.dylib               0x192235f2c _dispatch_barrier_sync_f_invoke + 48
18  CoreData                        0x185a71d00 -[NSManagedObjectContext performBlockAndWait:] + 132
19  gamed                           0x10009ce08 0x100048000 + 347656
20  gamed                           0x1000ba8a4 0x100048000 + 469156
21  libdispatch.dylib               0x192230420 _dispatch_call_block_and_release + 24
22  libdispatch.dylib               0x1922303e0 _dispatch_client_callout + 16
23  libdispatch.dylib               0x192235930 _dispatch_async_redirect_invoke + 152
24  libdispatch.dylib               0x1922303e0 _dispatch_client_callout + 16
25  libdispatch.dylib               0x1922373fc _dispatch_root_queue_drain + 400
26  libdispatch.dylib               0x192237638 _dispatch_worker_thread2 + 76
27  libsystem_pthread.dylib         0x1923c5918 _pthread_wqthread + 356
28  libsystem_pthread.dylib         0x1923c57a8 start_wqthread + 4

其他信息我返回并添加了有关removeMatch的日志记录。这种日志记录来自沙箱,但在生产中也会发生。

请注意,就在比赛取消之前,游戏已经处于最终状态(status:GKTurnBasedMatchStatusEnded)。

我一取消比赛,就试图开始一场新的比赛。第一次尝试得到"The operation couldn’t be completed. (Cocoa error 4097.)",第二次尝试在近2分钟后得到GKServerStatusCode=5000,因为玩家不再经过身份验证。

2014-01-19 22:23:31.436 KingChase[3432:70b] removing match <GKTurnBasedMatch 0xc50d8f0 - matchID:e0e24a77-fb5c-46a7-b843-21e8becf9735 bundleID:us.pojo.kingchase status:GKTurnBasedMatchStatusEnded message:'Game Over! kctest2 won.' creationDate:2014-01-20 04:17:31 +0000 currentParticipant:(null) participants:<GKTurnBasedParticipant 0xc4e9870 - playerID:G:1972295489 (local player) status:Done matchOutcome:Won lastTurnDate:2014-01-20 04:22:50 +0000 timeoutDate:(null)>,<GKTurnBasedParticipant 0xc439aa0 - playerID:G:1972168157 status:Done matchOutcome:Lost lastTurnDate:2014-01-20 04:23:17 +0000 timeoutDate:(null)> matchData.length:438 matchDataMaximumSize:65536 exchanges:(null)>
2014-01-19 22:23:31.441 KingChase[3432:70b] Match removed.
2014-01-19 22:23:31.442 KingChase[3432:70b] Match cleaned up.
2014-01-19 22:23:40.681 KingChase[3432:70b] Match Making failed. Error Domain=NSCocoaErrorDomain Code=4097 "The operation couldn’t be completed. (Cocoa error 4097.)"
2014-01-19 22:25:30.053 KingChase[3432:70b] Match Making failed. Error Domain=GKErrorDomain Code=6 "The requested operation could not be completed because local player has not been authenticated." UserInfo=0xc527430 {GKServerStatusCode=5000, NSUnderlyingError=0xc5222b0 "The operation couldn’t be completed. status = 5000, missing required header: x-gk-player-id", NSLocalizedDescription=The requested operation could not be completed because local player has not been authenticated.}

另一个玩家可以删除游戏而不会崩溃。

更新时间:2014年1月20日-CDT下午6:32-更多信息

我在使用GameKit进行的每一次交互中都添加了日志记录。

Jan 20 17:39:17 Ben-L-iPhone KingChase[3154] <Warning>: GK: [match.currentParticipant.playerID isEqualToString:localPlayer.playerID]
Jan 20 17:39:17 Ben-L-iPhone KingChase[3154] <Warning>: GK: [match participantQuitOutOfTurnWithOutcome:GKTurnBasedMatchOutcomeQuit withCompletionHandler:completionHandler];
Jan 20 17:39:18 Ben-L-iPhone KingChase[3154] <Warning>: removing match <GKTurnBasedMatch 0x1669bdb0 - matchID:a182e163-8006-413e-a203-c93d534ac550 bundleID:us.pojo.kingchase status:GKTurnBasedMatchStatusEnded message:'Game Over! kctest1 won.' creationDate:2014-01-20 23:12:32 +0000 currentParticipant:(null) participants:<GKTurnBasedParticipant 0x166ae6f0 - playerID:G:1972168157 (local player) status:Done matchOutcome:Won lastTurnDate:2014-01-20 23:27:14 +0000 timeoutDate:(null)>,<GKTurnBasedParticipant 0x1664d260 - playerID:G:1972295489 status:Done matchOutcome:Lost lastTurnDate:2014-01-20 23:38:15 +0000 timeoutDate:(null)> matchData.length:390 matchDataMaximumSize:65536 exchanges:(null)>
Jan 20 17:39:18 Ben-L-iPhone KingChase[3154] <Warning>: GK: [match removeWithCompletionHandler:^(NSError *error)
Jan 20 17:39:18 Ben-L-iPhone KingChase[3154] <Warning>: Match removed.
Jan 20 17:39:18 Ben-L-iPhone KingChase[3154] <Warning>: Match cleaned up.
Jan 20 17:39:19 Ben-L-iPhone gamed[3125] <Error>: *** Terminating app due to uncaught exception 'NSObjectInaccessibleException', reason: 'CoreData could not fulfill a fault for '0xd00000000024001a <x-coredata://3A4F66E1-B95C-4692-B905-EA1398FB97CE/TurnBasedSession/p9>''
*** First throw call stack:
(0x185ce309c 0x191c61d78 0x1859eb7ac 0x1859fc50c 0x1859fc47c 0x185a7475c 0x185a79034 0x185a797f4 0x185a7a474 0x1922303e0 0x192235d88 0x185a6f3e4 0x185a7a104 0x1859fdbd0 0x10014d284 0x185a71b6c 0x1922303e0 0x192235f2c 0x185a71d00 0x100150e08 0x10016e8a4 0x192230420 0x1922303e0 0x192235930 0x1922303e0 0x1922373fc 0x192237638 0x1923c5918 0x1923c57a8)

我想这和我打电话给有关

[match participantQuitOutOfTurnWithOutcome:GKTurnBasedMatchOutcomeQuit withCompletionHandler:completionHandler];

在游戏已经完成之后。我会在有时间的时候测试这个假设,并将错误报告提交给苹果。

我已经发现,当您从另一个GameKit调用的完成处理程序中调用[match removeWithCompletionHandler:^(NSError *error)]时,会出现这个问题。

如果你查看上面的日志:

[match participantQuitOutOfTurnWithOutcome:GKTurnBasedMatchOutcomeQuit withCompletionHandler:completionHandler];

被调用,并且该方法的completionHandler正在调用-removeWithCompletionHandler:

我使用这个更改解决了这个问题:

通过以下方式执行removeWithCompletionHandler:

[match performSelector:@selector(removeWithCompletionHandler:) withObject:^(NSError *error) {} afterDelay:5.0];

最新更新