From f2ff953ef7c284548a92833b6322dc51f444c902 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 26 Mar 2020 13:42:56 -0400 Subject: [PATCH] cocoa: Just update the OpenGL context directly if on the main thread. --- src/video/cocoa/SDL_cocoaopengl.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/video/cocoa/SDL_cocoaopengl.m b/src/video/cocoa/SDL_cocoaopengl.m index 74e93ed10eba2..c4db2565b33e5 100644 --- a/src/video/cocoa/SDL_cocoaopengl.m +++ b/src/video/cocoa/SDL_cocoaopengl.m @@ -66,7 +66,11 @@ - (void)updateIfNeeded int value = SDL_AtomicSet(&self->dirty, 0); if (value > 0) { /* We call the real underlying update here, since -[SDLOpenGLContext update] just calls us. */ - [super performSelectorOnMainThread:@selector(update) withObject:nil waitUntilDone:NO]; + if ([NSThread isMainThread]) { + [super update]; + } else { + [super performSelectorOnMainThread:@selector(update) withObject:nil waitUntilDone:NO]; + } } }