From 82e52c32a6f60670ba16e94add09374c57b802f2 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 29 Oct 2019 10:58:59 +0300 Subject: [PATCH] Fix crash on exit or resume on iOS 13 Fixes #7966. (cherry picked from commit 29bde8cd74bf6640058143aeafb0281c1b3a027f) --- platform/iphone/gl_view.mm | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm index 1af0100cc3f..3238f7c5c26 100644 --- a/platform/iphone/gl_view.mm +++ b/platform/iphone/gl_view.mm @@ -330,7 +330,6 @@ static void clear_touches() { [self destroyFramebuffer]; [self createFramebuffer]; [self drawView]; - [self drawView]; } - (BOOL)createFramebuffer { @@ -446,22 +445,22 @@ static void clear_touches() { // Updates the OpenGL view when the timer fires - (void)drawView { - if (useCADisplayLink) { - // Pause the CADisplayLink to avoid recursion - [displayLink setPaused:YES]; - - // Process all input events - while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE) == kCFRunLoopRunHandledSource) - ; - - // We are good to go, resume the CADisplayLink - [displayLink setPaused:NO]; - } if (!active) { printf("draw view not active!\n"); return; }; + if (useCADisplayLink) { + // Pause the CADisplayLink to avoid recursion + [displayLink setPaused:YES]; + + // Process all input events + while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.0, TRUE) == kCFRunLoopRunHandledSource) + ; + + // We are good to go, resume the CADisplayLink + [displayLink setPaused:NO]; + } // Make sure that you are drawing to the current context [EAGLContext setCurrentContext:context];