cocoa: Re-add sync timeout

This should never happen, but it's a failsafe against future bugs or odd configurations
This commit is contained in:
Frank Praznik
2025-03-26 18:01:42 -04:00
parent 2e61b41652
commit 05d23cae73

View File

@@ -3265,14 +3265,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;