2

正如标题所说——我的 Sprite Kit 游戏在后台时不时地崩溃,总是出现这个错误——

Exception Type:  EXC_BAD_ACCESS (SIGSEGV) 
Exception Subtype: KERN_INVALID_ADDRESS at 0x00000001
Triggered by Thread:  0
Thread 0 Crashed:

0   libGPUSupportMercury.dylib      0x3220193a gpus_ReturnNotPermittedKillClient + 10
1   libGPUSupportMercury.dylib      0x322023d4 gpusSubmitDataBuffers + 100
2   IMGSGX543RC2GLDriver            0x2c6211c4 SubmitPackets + 120
3   GLEngine                        0x2fb3bcda gliPresentViewES + 162
4   OpenGLES                        0x2fb46134 -[EAGLContext presentRenderbuffer:] + 60
5   SpriteKit                       0x2ffb0060 -[SKView _renderContent] + 1216
6   libdispatch.dylib               0x381120ec _dispatch_client_callout + 20
7   libdispatch.dylib               0x381168f6 _dispatch_barrier_sync_f_invoke + 22
8   SpriteKit                       0x2ffafb6e -[SKView renderContent] + 78
9   SpriteKit                       0x2ffad516 __29-[SKView setUpRenderCallback]_block_invoke + 126
10  SpriteKit                       0x2ffcfc84 -[SKDisplayLink _callbackForNextFrame:] +     252
11  QuartzCore                      0x2fd9003e CA::Display::DisplayLinkItem::dispatch() +     94
12  QuartzCore                      0x2fd8fde8 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 340
13  IOMobileFramebuffer             0x329b876a IOMobileFramebufferVsyncNotifyFunc + 102
14  IOKit                           0x2e614e6a IODispatchCalloutFromCFMessage + 246
15  CoreFoundation                  0x2d8f2b86 __CFMachPortPerform + 134
16  CoreFoundation                  0x2d8fd77c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
17  CoreFoundation                  0x2d8fd716 __CFRunLoopDoSource1 + 342
18  CoreFoundation                  0x2d8fbee2 __CFRunLoopRun + 1402
19  CoreFoundation                  0x2d86653c CFRunLoopRunSpecific + 520
20  CoreFoundation                  0x2d86631e CFRunLoopRunInMode + 102
21  GraphicsServices                0x3259d2e6 GSEventRunModal + 134
22  UIKit                           0x3011d1e0 UIApplicationMain + 1132
23  NoCar7                          0x0010c186 0xf9000 + 78214
24  libdyld.dylib                   0x38126ab4 start + 0

Thread 1:
0   libsystem_kernel.dylib          0x381ca838 kevent64 + 24
1   libdispatch.dylib               0x381190d0 _dispatch_mgr_invoke + 228
2   libdispatch.dylib               0x3811363e _dispatch_mgr_thread + 34

Thread 2:
0   libsystem_kernel.dylib          0x381ddc7c __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x38241e06 _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x38241cc0 start_wqthread + 4

Thread 3:
0   libsystem_kernel.dylib          0x381ddc7c __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x38241e06 _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x38241cc0 start_wqthread + 4

Thread 4:
0   libsystem_kernel.dylib          0x381ddc7c __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x38241e06 _pthread_wqthread + 306
2   libsystem_pthread.dylib         0x38241cc0 start_wqthread + 4

Thread 5:
0   libsystem_kernel.dylib          0x381caa84 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x381ca87c mach_msg + 36
2   AudioToolbox                    0x2d26d99c AURemoteIO::IOThread::Run() + 184
3   AudioToolbox                    0x2d271438 AURemoteIO::IOThread::Entry(void*) + 4
4   AudioToolbox                    0x2d19f2ac CAPThread::Entry(CAPThread*) + 208
5   libsystem_pthread.dylib         0x38243c5a _pthread_body + 138
6   libsystem_pthread.dylib         0x38243bca _pthread_start + 98
7   libsystem_pthread.dylib         0x38241ccc thread_start + 4

Thread 0 crashed with ARM Thread State (32-bit):
r0: 0xdeadbeef    r1: 0x00000001      r2: 0x1b48d000      r3: 0x00000044
r4: 0x00000000    r5: 0x04e5d560      r6: 0x04e5d438      r7: 0x27d088c0
r8: 0x00000000    r9: 0x00000fff     r10: 0x04e5d000     r11: 0x04e5b90f
ip: 0x3a004114    sp: 0x27d088a0      lr: 0x322023d9      pc: 0x3220193a
cpsr: 0x20000030

什么会导致它?

4

3 回答 3

3

问题可能是由音频引起的,如果是这样,您可以在此处查看答案https://stackoverflow.com/a/19283721/1278463

我在不使用音频的游戏中解决了这个问题。解决方案是在进入后台时暂停 SKView:

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    SKView *view = (SKView *)self.window.rootViewController.view;
    if (view) {
        view.paused = YES;
    }
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    SKView *view = (SKView *)self.window.rootViewController.view;
    if (view) {
        view.paused = NO;
    }
}
于 2014-06-19T15:19:17.453 回答
2

对我来说,暂停SKView并使用[[SKView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]而不是[[SKView alloc] init]解决问题!

[[SKView alloc] init]似乎被窃听了!

于 2014-01-22T22:08:18.680 回答
0

这很可能是 SpriteKit 中的一个错误。查看此线程以获取解决方案:SpriteKit-多任务的正确方法

于 2013-10-19T19:05:42.830 回答