按Home键切换到后台后会触发libGPUSupportMercury.dylib: gpus_ReturnNotPermittedKillClient导致crash

本文探讨了iOS应用在真机调试时遇到的问题:当从后台返回时App崩溃或僵死的情况。问题根源在于AppDelegate中对CCDirector的处理不当。文章提供了具体的代码修改方案,以确保App在后台不会调用OpenGL,避免崩溃。

苹果解读:

http://developer.apple.com/library/ios/#qa/qa1766/_index.html


转自:http://www.eoeandroid.com/thread-251598-1-1.html


好像有很多朋友都碰到过这个问题,即在真机调试时,按hone键返回桌面,再回到app时,app会crash或僵死。同时xcode停留在:
libGPUSupportMercury.dylib`gpus_ReturnNotPermittedKillClient:
0x372fa094: trap
0x372fa096: nop


原因在于AppDelegate.cpp里

void AppDelegate::applicationDidEnterBackground()

{

    CCDirector::sharedDirector()->pause();


}

void AppDelegate::applicationWillEnterForeground()

{

    CCDirector::sharedDirector()->resume();


}

director在app切换至后台时若被pause,它其实并没有真正暂停,而是仍保持着每秒4帧的绘制速率。但在app处于后台时,ios是不允许app调opengl的。这个原因引发了上述问题。

解决方法是:
void AppDelegate::applicationDidEnterBackground()
{
    CCDirector::sharedDirector()->stopAnimation();
}
void AppDelegate::applicationWillEnterForeground()
{
    CCDirector::sharedDirector()->startAnimation();
}

stopAnimation()才让director真正暂停下来。



另:播放视频时按home键crash问题:
http://blog.k-res.net/archives/1193.html


评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值