فهرست منبع

cocoa: Re-add sync timeout

This should never happen, but it's a failsafe against future bugs or odd configurations

(cherry picked from commit 05d23cae736bb4d362ead87571c210451c7a3859)
Frank Praznik 3 هفته پیش
والد
کامیت
361218ce15
1فایلهای تغییر یافته به همراه12 افزوده شده و 3 حذف شده
  1. 12 3
      src/video/cocoa/SDL_cocoawindow.m

+ 12 - 3
src/video/cocoa/SDL_cocoawindow.m

@@ -3264,14 +3264,23 @@ bool Cocoa_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float op
 
 bool Cocoa_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window)
 {
-    bool result = true;
+    bool result = false;
 
     @autoreleasepool {
+        const Uint64 timeout = SDL_GetTicksNS() + SDL_MS_TO_NS(2500);
         SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal;
 
-        do {
+        for (;;) {
             SDL_PumpEvents();
-        } while ([data.listener hasPendingWindowOperation]);
+
+            result = ![data.listener hasPendingWindowOperation];
+            if (result || SDL_GetTicksNS() >= timeout) {
+                break;
+            }
+
+            // Small delay before going again.
+            SDL_Delay(10);
+        }
     }
 
     return result;