iOS: Also do the Dictation crash workaround before executing the animation callback.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
diff --git a/src/video/uikit/SDL_uikitevents.m b/src/video/uikit/SDL_uikitevents.m
index 398d497..7083e20 100644
--- a/src/video/uikit/SDL_uikitevents.m
+++ b/src/video/uikit/SDL_uikitevents.m
@@ -26,6 +26,7 @@
#include "SDL_uikitvideo.h"
#include "SDL_uikitevents.h"
+#include "SDL_uikitopengles.h"
#import <Foundation/Foundation.h>
@@ -63,19 +64,8 @@ UIKit_PumpEvents(_THIS)
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];
- }
- }
+ /* See the comment in the function definition. */
+ UIKit_GL_RestoreCurrentContext();
}
#endif /* SDL_VIDEO_DRIVER_UIKIT */
diff --git a/src/video/uikit/SDL_uikitopengles.h b/src/video/uikit/SDL_uikitopengles.h
index 1069761..b52e429 100644
--- a/src/video/uikit/SDL_uikitopengles.h
+++ b/src/video/uikit/SDL_uikitopengles.h
@@ -33,6 +33,8 @@ extern void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context);
extern void *UIKit_GL_GetProcAddress(_THIS, const char *proc);
extern int UIKit_GL_LoadLibrary(_THIS, const char *path);
+extern void UIKit_GL_RestoreCurrentContext();
+
#endif
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/uikit/SDL_uikitopengles.m b/src/video/uikit/SDL_uikitopengles.m
index a2ea4ab..4bca178 100644
--- a/src/video/uikit/SDL_uikitopengles.m
+++ b/src/video/uikit/SDL_uikitopengles.m
@@ -217,6 +217,24 @@ UIKit_GL_DeleteContext(_THIS, SDL_GLContext context)
}
}
+void
+UIKit_GL_RestoreCurrentContext()
+{
+ @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 */
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/uikit/SDL_uikitviewcontroller.m b/src/video/uikit/SDL_uikitviewcontroller.m
index 58cdf1a..62af310 100644
--- a/src/video/uikit/SDL_uikitviewcontroller.m
+++ b/src/video/uikit/SDL_uikitviewcontroller.m
@@ -33,6 +33,7 @@
#include "SDL_uikitvideo.h"
#include "SDL_uikitmodes.h"
#include "SDL_uikitwindow.h"
+#include "SDL_uikitopengles.h"
#if SDL_IPHONE_KEYBOARD
#include "keyinfotable.h"
@@ -102,6 +103,9 @@
{
/* Don't run the game loop while a messagebox is up */
if (!UIKit_ShowingMessageBox()) {
+ /* See the comment in the function definition. */
+ UIKit_GL_RestoreCurrentContext();
+
animationCallback(animationCallbackParam);
}
}