1

I am using OpenGL ES to render a scene on a CADisplayLink with:

self.displayLink = CADisplayLink(target: self, selector: #selector(self.updateOpenGL))
self.displayLink!.frameInterval = 1 
self.displayLink!.addToRunLoop(NSRunLoop.currentRunLoop(), forMode: NSDefaultRunLoopMode)

If I background the app and go to the Spring Board, when I resume the app, the rendering continues.

But if I background the app, open another app such as Calendar, when I bring the app back to the foreground, there is no more rendering to the screen. If I pause the execution with Xcode, or stop at a breakpoint in the rendering pipeline, the DisplayLink is still running and executing my OpenGL rendering code.

Any ideas why?

Jeshua Lacock
  • 5,730
  • 1
  • 28
  • 58

1 Answers1

1

OpenGL ES context are not guaranteed to be maintained overtime when an App goes to background and returns. The App has to handle this, as the OS might delete the context if another app loads OpenGL ES.

Your OpenGL ES app is in the background when the user launches another OpenGL ES app. If that app needs more memory than is available on the device, the system silently and automatically terminates your app without requiring it to perform any additional work.

This information is from the Apple Document OpenGLES Programming Guide

codetiger
  • 2,650
  • 20
  • 37
  • I am aware apps are responsible for saving their state - in the event they are terminated. But are you suggesting that Calendar is launching an OpenGL ES instance? Seems odd - in fact when I launch Calendar it just shows its welcome screen (since I haven't used it before). – Jeshua Lacock Aug 27 '16 at 05:22
  • Am not trying to say that Calendar app uses OpenGLES, but there is many factors why OpenGLEs context is getting deleted. There could be one reason that you are passing a GL command after the app goes to background. This is highly probable to get your context killed. – codetiger Aug 27 '16 at 05:25