cocoa: Re-add sync timeout

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

(cherry picked from commit 05d23cae73)
This commit is contained in:
Frank Praznik committed 2025-03-27 11:59:09 -04:00
1 parent 04dcfada00
commit 361218ce15
1 file changed
+12 -3
+12 -3
View File
@@ -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 Cocoa_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window)
{ {
bool result = true; bool result = false;
@autoreleasepool { @autoreleasepool {
const Uint64 timeout = SDL_GetTicksNS() + SDL_MS_TO_NS(2500);
SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal;
do { for (;;) {
SDL_PumpEvents(); 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; return result;