How to fix OpenGL ES application crashes when moving to the background
来源:互联网 发布:java实现转盘抽奖系统 编辑:程序博客网 时间:2024/04/27 23:33
对于iOS应用 OpenGL的渲染如在在应用进入后台后仍在渲染 则APP会crash
iOS apple 官方文档
Background Apps May Not Execute Commands on the Graphics Hardware
An OpenGL ES app is terminated if it attempts to execute OpenGL ES commands on the graphics hardware. iOS prevents background apps from accessing the graphics processor so that the frontmost app is always able to present a great experience to the user. Your app can be terminated not only if it makes OpenGL ES calls while in the background but also if previously submitted commands are flushed to the GPU while in the background. Your app must ensure that all previously submitted commands have finished executing before moving into the background.
If you use a GLKit view and view controller, and only submit OpenGL ES commands during your drawing method, your app automatically behaves correctly when it moves to the background. The GLKViewController
class, by default, pauses its animation timer when your app becomes inactive, ensuring that your drawing method is not called.
If you do not use GLKit views or view controllers or if you submit OpenGL ES commands outside a GLKView
drawing method, you must take the following steps to ensure that your app is not terminated in the background:
In your app delegate’s
applicationWillResignActive:
method, your app should stop its animation timer (if any), place itself into a known good state, and then call theglFinish
function.In your app delegate’s
applicationDidEnterBackground:
method, your app may want to delete some of its OpenGL ES objects to make memory and resources available to the foreground app. Call theglFinish
function to ensure that the resources are removed immediately.After your app exits its
applicationDidEnterBackground:
method, it must not make any new OpenGL ES calls. If it makes an OpenGL ES call, it is terminated by iOS.In your app’s
applicationWillEnterForeground:
method, re-create any objects and restart your animation timer.
To summarize, your app needs to call the glFinish
function to ensure that all previously submitted commands are drained from the command buffer and are executed by OpenGL ES. After it moves into the background, you must avoid all use of OpenGL ES until it moves back into the foreground.
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libGPUSupportMercury.dylib 0x30570094 gpus_ReturnNotPermittedKillClient + 0
1 libGPUSupportMercury.dylib 0x305700ae gpus_KillClient ( )
2 libGPUSupportMercury.dylib 0x305705ba gpusSubmitDMABuffers ( )
3 IMGSGX535GLDriver 0x34bd29b8 SubmitPacketsIfAny ( )
4 IMGSGX535GLDriver 0x34bd2ad0 glrFlushContextToken ( )
5 GLEngine 0x37719c4a gliPresentViewES ( )
6 OpenGLES 0x323df6b4 -[EAGLContext presentRenderbuffer:] ( )
...
...
可以参看此文档 https://developer.apple.com/library/content/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/ImplementingaMultitasking-awareOpenGLESApplication/ImplementingaMultitasking-awareOpenGLESApplication.html#//apple_ref/doc/uid/TP40008793-CH5-SW1
但是并没有给出解决办法 还是在进入后台时停止所有的OpenGL渲染吧。
参考:https://developer.apple.com/library/content/qa/qa1766/_index.html
- How to fix OpenGL ES application crashes when moving to the background
- 每日刷题(2015/6/23)You are given the source to an application which crashes when it is run.
- how to fix the problem when you install matlab on *nix-- "libXp.so.6 : cannot open "
- how to fix the assembly problem when project A call project B as reference
- How to study Android OpenGL ES
- How to study Android OpenGL ES
- how to fix the frame size?
- How to fix Rosetta stone error 2123 -- "This was an error in the application"
- how to debug the background job
- How to fix the problem that the Download rate is too Slow when doing "apt-get install"
- how to disable the button when submitting
- How to fix the bug 640*480 resolution only when install ubuntu 14.04 on a old laptop?
- how to create colored 3D Objects using the OpenGL® ES cross-platform API.
- How to Manage Oracle Application Workflow Background Process Concurrent Program
- Java EE 6: How to implement “Stay Logged In” when user login in to the web application
- How to develop OpenGL ES (GLES) 2.0 applications on Linux
- How to fix the problem of " Session Lost "
- How to fix the Android AVD no target problem
- npm run webpack 报错找不到啥啥依赖
- POJ3087 Shuffle'm Up —— 打表找规律 / map判重
- SPOJ104:Highways(矩阵树定理)
- 设计模式之单例模式(一)
- (HDU
- How to fix OpenGL ES application crashes when moving to the background
- MTCNN代码实现
- 图像旋转
- 数据库:drop、delete与truncate
- JVM(一) OpenJDK1.8源码在Ubuntu16.04下的编译
- Android之一个很奇怪的生命周期bug
- Warning: Error while sending QUERY packet. PID=28044
- 关于平方根的最大下取整数的java代码解决方案
- vue-router -- 命名路由和命名视图