0

We are developing a SpriteKit iOS7 game,the game works very well, but the game crashes when it is sent to background if we integrated any of the following libs: - Airship. - Bugsense. - Apptentive.

Here is the Crashlytics crash report:

Thread : Crashed: com.apple.spritekit.renderQueue

0  libGPUSupportMercury.dylib     0x3478b8f6 gpus_ReturnNotPermittedKillClient
1  libGPUSupportMercury.dylib     0x3478c391 gpusSubmitDataBuffers
2  IMGSGX543GLDriver              0x2ec9982d SubmitPackets
3  GLEngine                       0x320fbc3d gliPresentViewES + 172
4  OpenGLES                       0x32106139 -[EAGLContext presentRenderbuffer:] + 64
5  SpriteKit                      0x325701b1 -[SKView _renderContent] + 1216
6  libdispatch.dylib              0x3a6fdd07 _dispatch_client_callout + 22
7  libdispatch.dylib              0x3a703b9f _dispatch_barrier_sync_f_invoke + 26
8  SpriteKit                      0x3256fcc3 -[SKView renderContent] + 82
9  SpriteKit                      0x3256d663 __29-[SKView setUpRenderCallback]_block_invoke + 130
10 SpriteKit                      0x3258fddb -[SKDisplayLink _callbackForNextFrame:] + 254
11 QuartzCore                     0x3234f9cf CA::Display::DisplayLinkItem::dispatch() + 98
12 QuartzCore                     0x3234f779 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 344
13 IOMobileFramebuffer            0x34f4576d IOMobileFramebufferVsyncNotifyFunc + 104
14 IOKit                          0x30be7a75 IODispatchCalloutFromCFMessage + 248
15 CoreFoundation                 0x2fec5e21 __CFMachPortPerform + 136
16 CoreFoundation                 0x2fed09df __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34
17 CoreFoundation                 0x2fed097b __CFRunLoopDoSource1 + 346
18 CoreFoundation                 0x2fecf14f __CFRunLoopRun + 1398
19 CoreFoundation                 0x2fe39c27 CFRunLoopRunSpecific + 522
20 CoreFoundation                 0x2fe39a0b CFRunLoopRunInMode + 106
21 GraphicsServices               0x34b29283 GSEventRunModal + 138
22 UIKit                          0x326dd049 UIApplicationMain + 1136
23 SplishyFish                    0x000a95d1 main (main.m:16)
Mohamed Saleh
  • 2,881
  • 1
  • 23
  • 35
  • `gpus_ReturnNotPermittedKillClient` almost always indicates that you're rendering OpenGL ES content while the application is in the background. Your application is killed instantly when that happens. You need to make sure that Sprite Kit won't try to render anything after you've started transitioning to the background. – Brad Larson Mar 04 '14 at 01:07
  • @BradLarson But why it only crashes when I include one of these libraries (Airship, Bugsense, or Apptentive) and didn't crash when i comment them all without changing any code in the sprite kit scene. What should I do with spritekit to make stop rendering when app is going to background? – Mohamed Saleh Mar 04 '14 at 18:13
  • Are you able to reproduce this in the debugger with the simulator ? It's possible you can narrow it down that way. – prototypical Mar 05 '14 at 02:25
  • @prototypical, same occurs in simulator and device – Mohamed Saleh Mar 05 '14 at 14:24
  • If it happens on the simulator and device, then are you catching where it happens with the debugger ? – prototypical Mar 05 '14 at 20:52

3 Answers3

2

Apptentive, at least, doesn't make any OpenGL calls. I suspect that adding the libraries to your app may just be exposing the issue that would happen in some other context (such as when there are pending events to process on the main run loop when the app is being backgrounded).

That said, the backtrace above is the same as the one in this thread:

Spritekit crashes when entering background

of which there is a solution proposed here:

Sprite Kit & playing sound leads to app termination

The problem there being audio playing while the app is being backgrounded. Might that be the issue?

If not, the other possible culprit would be OpenGL rendering, as others have said.

Community
  • 1
  • 1
  • thanks for your reply, I agree for the point of that other libs shouldn't be the cause of the problem, and yes I have tried and checked all the issue you have posted before posting mine here and neither solved the problem,thanks for your help. – Mohamed Saleh Mar 05 '14 at 23:34
1

I encountered the same issue in Swift and I solved the problem with the following code:

func applicationDidEnterBackground(application: UIApplication)
{
    var skView:SKView = self.window?.rootViewController?.view as! SKView
    skView.paused = true
}


func applicationWillEnterForeground(application: UIApplication)
{
    var skView:SKView = self.window?.rootViewController?.view as! SKView
    skView.paused = false        
}
superm0
  • 963
  • 11
  • 19
0

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;
    }
}
Borislav Gizdov
  • 1,323
  • 12
  • 22