From ddb11ec3bb864b72a334724ce565ac5a0be54e14 Mon Sep 17 00:00:00 2001 From: Greg Lucas Date: Fri, 26 Nov 2021 21:37:27 -0700 Subject: [PATCH] FIX: Add a 0-length timer to allow fast animations to redraw on macosx The macosx backend would not update on flush_events calls due to the loop being run too fast for the view to update properly in the NSApp. Fix that by adding an unnoticeable RunLoop timer slowdown that allows the app to see the changes. --- src/_macosx.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/_macosx.m b/src/_macosx.m index e961e306ed76..b50b59d37bd8 100755 --- a/src/_macosx.m +++ b/src/_macosx.m @@ -393,6 +393,9 @@ static CGFloat _get_device_scale(CGContextRef cr) PyErr_SetString(PyExc_RuntimeError, "NSView* is NULL"); return NULL; } + // We need to interrupt the runloop very briefly to allow the view to be + // displayed when used in a fast updating animation + [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.0]]; [view displayIfNeeded]; Py_RETURN_NONE; }