SpriteKit Crashing On Entering Background with [Fl

2019-08-15 08:10发布

I have googled this, and I found many debates over this, what i understand is this problem is related to rendering of OpenGl of Spritekit, Some people were facing this problem when they were playing AUdio with Spritekit.

While My case is different i am facing this when i integerate Flurry publisher Api using the Function

In [Flurry startSession:FlurryAPPKey];

in APPDelegete File

Commenting out the above code removed the problem.

I think there are a couple of things that when you integerate with SpriteKit this Happens as i found on google, like AVAudioSession, etc,

I just wanted to know, what is the best practice to avoid such rendering problem, or this may really be happening with Flurry Sdk 4.4.2? don't know but the backtrace is showing

#0  0x3311b932 in gpus_ReturnNotPermittedKillClient ()
#24 0x31032844 in UIApplicationMain ()
#25 0x0004cd16 in main at ....

here is the link of sample code Flurry SpriteKit

1条回答
Summer. ? 凉城
2楼-- · 2019-08-15 08:37

You should always pause your SKView upon backgrounding. This will prevent SpriteKit from generating the gpus_ReturnNotPermittedKillClient exception. It seems that some services which perform background work, such as Flurry & AVAudioSession, interfere with SpriteKit in this way. So to prevent this you can do the following.

// Register for relevant application lifecycle notifications
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(applicationWillResignActive)
                                             name:UIApplicationWillResignActiveNotification
                                           object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(applicationDidBecomeActive)
                                             name:UIApplicationDidBecomeActiveNotification
                                           object:nil];

// Pause/Unpause SKView instance
- (void)applicationWillResignActive
{
    [[self skView] setPaused:YES];
}

- (void)applicationDidBecomeActive
{
    [[self skView] setPaused:NO];
}
查看更多
登录 后发表回答