Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gpus_ReturnNotPermittedKillClient error thrown with MKMapView when app is backgrounded

Doing some investigation online, I've noticed that gpus_ReturnNotPermittedKillClient gets thrown when OpenGL actions are triggered while an app is backgrounded. I'm currently working on a project that involves a map view and an overlay (using Apple's Breadcrumb sample code). These actions are performed on the main thread, but there's a possibility that the app could get backgrounded as the map view becomes initialized or the view gets pushed onto the screen.

I also use location services to retrieve points through GPS, but I don't update the overlay unless we're in the foreground.

Is it to my understanding that since iOS 6, MKMapView's are now created with OpenGL? If this is the case, then could drawing the overlay also be through OpenGL? This could help explain why I've been getting this error randomly.

I've heard of some ways to cancel all OpenGL actions, such as invoking glFinish() in applicationDidEnterBackground and applicationWillResignActive or using [[CCDirector sharedDirector] pause]. Considering this, what would be the best solution to eliminate any OpenGL drawing with an MKMapView/MKOverlayView?

like image 350
SpacePyro Avatar asked Jan 22 '13 22:01

SpacePyro


1 Answers

After trying multiple solutions, I realized that the thing that was causing this crash was an adjustment of the map view's frame that was being fired off a few seconds after the map was allocated. A status bar is dropped down, and the map's frame was animated downward by a few pixels. Because of this, the map (supposedly) had to be re-drawn, causing a crash if this animation was occurring in the background.

I now keep track of the state of the status bar in relation to the app's active status, and only animate if the application state is UIApplicationStateActive. Having done this, I haven't had a crash since.

like image 132
SpacePyro Avatar answered Nov 08 '22 20:11

SpacePyro