iOS app sent to background, gets EXC_BAD_ACCESS

I was just testing an app on an iPhone 5 and haven’t been able to get
around a particular crash. About 2 seconds after I send the app to the
background by pressing the Home button, it crashes with EXC_BAD_ACCESS
(with address 1) on line 319 of SDL_uikitopenglview.m (in swapBuffers()):
[context presentRenderbuffer:GL_RENDERBUFFER];

It seems to me that being in the background is doing something bad to the
renderBuffer handle and trying to swapBuffers won’t work.

I updated to the latest in hg and still got this crash. I also tried
rebinding the renderBuffer in case it was getting unbound by the
backgrounding, but that wasn’t it.

Has anyone else had this problem? If not, I’ll see about building a
different app to see if it happens there too.

Jonny D

On iOS when using OpenGL directly, you?ll need to add an SDL event watch callback for the SDL_APP_DIDENTERBACKGROUND event. The callback function should call glFinish, and after that you should make sure that no other OpenGL functions (including SwapBuffers) are called until SDL_APP_WILLENTERFOREGROUND is triggered.

https://developer.apple.com/library/ios/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/ImplementingaMultitasking-awareOpenGLESApplication/ImplementingaMultitasking-awareOpenGLESApplication.html> On Oct 26, 2015, at 10:53 AM, Jonathan Dearborn wrote:

I was just testing an app on an iPhone 5 and haven’t been able to get around a particular crash. About 2 seconds after I send the app to the background by pressing the Home button, it crashes with EXC_BAD_ACCESS (with address 1) on line 319 of SDL_uikitopenglview.m (in swapBuffers()):
[context presentRenderbuffer:GL_RENDERBUFFER];

It seems to me that being in the background is doing something bad to the renderBuffer handle and trying to swapBuffers won’t work.

I updated to the latest in hg and still got this crash. I also tried rebinding the renderBuffer in case it was getting unbound by the backgrounding, but that wasn’t it.

Has anyone else had this problem? If not, I’ll see about building a different app to see if it happens there too.

Jonny D


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Thanks Alex! That’s the tip I needed.

I do have a callback to handle those events, but am only saving state when
backgrounded and did not heed the advice to “Stop loops, etc.” and “Restart
your loops here.”. So my app was being naughty and making GL ES calls in
the background.

Perhaps we can make the ios readme more specific on this point? I ignored
this advice because it didn’t seem important as my app does very little
work even in the foreground.

Jonny DOn Mon, Oct 26, 2015 at 9:40 PM, Alex Szpakowski wrote:

On iOS when using OpenGL directly, you?ll need to add an SDL event watch
callback for the SDL_APP_DIDENTERBACKGROUND event. The callback function
should call glFinish, and after that you should make sure that no other
OpenGL functions (including SwapBuffers) are called until
SDL_APP_WILLENTERFOREGROUND is triggered.

https://developer.apple.com/library/ios/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/ImplementingaMultitasking-awareOpenGLESApplication/ImplementingaMultitasking-awareOpenGLESApplication.html

On Oct 26, 2015, at 10:53 AM, Jonathan Dearborn <@Jonathan_Dearborn> wrote:

I was just testing an app on an iPhone 5 and haven’t been able to get
around a particular crash. About 2 seconds after I send the app to the
background by pressing the Home button, it crashes with EXC_BAD_ACCESS
(with address 1) on line 319 of SDL_uikitopenglview.m (in swapBuffers()):
[context presentRenderbuffer:GL_RENDERBUFFER];

It seems to me that being in the background is doing something bad to
the renderBuffer handle and trying to swapBuffers won’t work.

I updated to the latest in hg and still got this crash. I also tried
rebinding the renderBuffer in case it was getting unbound by the
backgrounding, but that wasn’t it.

Has anyone else had this problem? If not, I’ll see about building a
different app to see if it happens there too.

Jonny D


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org