From 49892b3ce8614aa4e3b3f847926622e726e5e679 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 17 Jan 2022 16:59:45 -0600 Subject: [PATCH] Only use SDL_WaitEventTimeout() on SDL 2.0.18+ --- app/streaming/session.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index cffa8f0e..50bfaf00 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -1443,11 +1443,16 @@ void Session::execInternal() SDL_Event event; Sint32 lastResizeW = -1, lastResizeH = -1; for (;;) { -#if SDL_VERSION_ATLEAST(2, 0, 16) && !defined(STEAM_LINK) - // SDL 2.0.16 has a proper wait event implementation that uses platform - // support to block on events rather than polling on Windows, macOS, and - // X11. It will fall back to 1 ms polling if a joystick is connected, so - // we don't use it for STEAM_LINK to ensure we only poll every 10 ms. +#if SDL_VERSION_ATLEAST(2, 0, 18) && !defined(STEAM_LINK) + // SDL 2.0.18 has a proper wait event implementation that uses platform + // support to block on events rather than polling on Windows, macOS, X11, + // and Wayland. It will fall back to 1 ms polling if a joystick is + // connected, so we don't use it for STEAM_LINK to ensure we only poll + // every 10 ms. + // + // NB: This behavior was introduced in SDL 2.0.16, but had a few critical + // issues that could cause indefinite timeouts, delayed joystick detection, + // and other problems. if (!SDL_WaitEventTimeout(&event, 1000)) { presence.runCallbacks(); continue;