iOS 多任务 applicationDidEnterBackground 返回时崩溃
我正在尝试适应 iOS4 上的多任务处理。我不是在后台运行,我只是想尽可能恢复到运行状态。我是个全GL游戏。
在 applicationWillResignActive 期间,我设置了停止 GL 渲染并整理并静默暂停游戏的标志。
在 applicationDidEnterBackground 期间,我释放屏幕缓冲区并调用 glFinish。
在 applicationWillEnterForeground 中,我再次分配缓冲区
,在 applicationWillEnterForeground 中,我取消暂停游戏。
现在,所有这些都被调用并且可以正常工作。即,如果我点击主页按钮,游戏就会消失,如果我点击图标,它就会以相同的状态返回。该应用程序不会被终止。这对于运行小型应用程序然后返回到我的应用程序是相同的。
但是,如果我运行一个大型应用程序(例如另一个游戏)并返回,我会返回最后渲染的帧。 5秒停顿。然后游戏重新启动,或者只是回到跳板。
我到处都有日志,并且在失败返回的调试器中,我没有收到对 applicationWillEnterForeground 或 applicationWillEnterForeground 的调用,我只得到 (gdb).
据我了解,如果系统需要我的内存,它就会被默默地杀死。这很好,因为当我进入后台时我会保存所有内容。那么为什么当我再次运行它时会得到最后一个渲染帧,并且为什么它只是有时启动有时崩溃?
有谁知道我在做什么丢失的?
谢谢
I'm trying to conform to multitasking on iOS4. I'm not running in the background, I just want to restore in a running state where possible. I'm an all GL game.
During applicationWillResignActive I set flags that stop GL rendering and tidy up and silently pause the game.
During applicationDidEnterBackground I release the screen buffers and call glFinish.
In applicationWillEnterForeground I allocate the buffers again
and in applicationWillEnterForeground I un-pause the game
Now, all these get called and it works. I.e. If I hit the home button the game goes away, if I tap the icon it comes back in the same state. The app doesn't get terminated. This is the same for running small apps and then going back to my app.
However, if I run a large app such as another game and come back I get the last rendered frame come back. A 5 second pause. Then the game reboots, or just drops back to springboard.
I've got logs everywhere, and in the debugger on the failed return I get no calls to either applicationWillEnterForeground or applicationWillEnterForeground, I just get a (gdb).
From what I understand, if the system needs my memory it'll be silently killed. This is fine as I save everything when I enter background. So why do I get the last render frame when I run it again, and why does it only sometimes boot and sometimes crash?
I've followed the guide here:
http://developer.apple.com/library/ios/#documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/ImplementingaMultitasking-awareOpenGLESApplication/ImplementingaMultitasking-awareOpenGLESApplication.html
Has anyone any idea what I'm missing?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论