Skip to content

Commit

Permalink
iOS: Workaround for a crash after Dictation is used.
Browse files Browse the repository at this point in the history
  • Loading branch information
slime73 committed Apr 1, 2016
1 parent f3ca4e4 commit 5520ed9
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/video/uikit/SDL_uikitevents.m
Expand Up @@ -62,6 +62,20 @@ touch events to get processed (which is important to get certain
do {
result = CFRunLoopRunInMode((CFStringRef)UITrackingRunLoopMode, seconds, TRUE);
} while(result == kCFRunLoopRunHandledSource);

@autoreleasepool {
/* Some iOS system functionality (such as Dictation on the on-screen
keyboard) uses its own OpenGL ES context but doesn't restore the
previous one when it's done. This is a workaround to make sure the
expected SDL-created OpenGL ES context is active after the OS is
finished running its own code for the frame. If this isn't done, the
app may crash or have other nasty symptoms when Dictation is used.
*/
EAGLContext *context = (__bridge EAGLContext *) SDL_GL_GetCurrentContext();
if (context != NULL && [EAGLContext currentContext] != context) {
[EAGLContext setCurrentContext:context];
}
}
}

#endif /* SDL_VIDEO_DRIVER_UIKIT */
Expand Down

0 comments on commit 5520ed9

Please sign in to comment.