Crash in background- Sprite-Kit related

2

As the title says- my Sprite Kit game crashes every now and then in background, always with this error-

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

What can cause it?

crash
ios7
multitasking
sprite-kit
asked on Stack Overflow Sep 27, 2013 by Lior Pollak

3 Answers

3

The problem can be caused by audio, if so you can check the answer here https://stackoverflow.com/a/19283721/1278463

I solved this in a game which is not using audio. Th solution is to pause SKView when entering background:

- (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;
    }
}
answered on Stack Overflow Jun 19, 2014 by Borislav Gizdov • edited May 23, 2017 by Community
2

For me, pausing the SKView and using [[SKView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)] instead of [[SKView alloc] init] solve the issue !

[[SKView alloc] init] seems to be bugged !

answered on Stack Overflow Jan 22, 2014 by Clement M • edited Feb 12, 2014 by James
0

It's most likely a bug within SpriteKit. Check out this thread for a solution: SpriteKit- the right way to multitask

answered on Stack Overflow Oct 19, 2013 by Benjamin Bojko • edited May 23, 2017 by Community

User contributions licensed under CC BY-SA 3.0