Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenGL ES application crashes when locked screen or entered background

My application is an OpenGL heavily employed one, which is being used to process images, rendering scenes, display previews, etc. However, after I implemented multi-task as Apple's official document 'OpenGL ES Programming Guide for iOS', weird crashes still came up sporadically. Debug Navigator Stack trace shows something like 'sgxPatchDeferredFramebufferOffsets', 'presentRenderbuffer EXC_BAD_ACCESS', 'gpus_ReturnNotPermittedKillClient', etc.

So, I would like to know what exactly one should implement OpenGL ES Multi-task.

=============UPDATE: Problem Solved============

Thanks for your answer, CStreel, and other guys who tried to help.

After reading 'Background Applications May Not Execute Commands on the Graphics Hardware' part in'OpenGL ES Programming Guide for iOS' a second time, line by line, I have a new understanding with this issue.

The big problem with my app is I should not implement OpenGL ES multi-task in a notification method. Since, unlike delegate methods, notification methods will be called asynchronously, these stopping animation actions and glFinish() calls may not take effect when the application has already moved into the background. This may happen more frequently when I hit the lock-screen button as soon as I am performing a series of OpenGL ES related actions.

If you guys found some other issues, feel free to contact me.

like image 288
cocoatoast Avatar asked Oct 06 '22 07:10

cocoatoast


1 Answers

When you app is about to enter the background, if your app calls any OGLES functions the OS will kill your app straight away

Read the App States & Multitasking for more information Read the Being a Responsible Background App

Here are some extracts from that document:

(Required) When moving to the background, make sure your app adjusts its behavior appropriately.

In regards to OGLES

 ...the app should stop calling OpenGL ES functions.
like image 185
CStreel Avatar answered Oct 10 '22 04:10

CStreel