From 64789ea8bcc1198048bdc44450b92831fa93442b Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 11 Sep 2023 21:07:54 -0500 Subject: [PATCH] Destroy the VTRenderer before leaving fullscreen Fixes #973 --- app/streaming/session.cpp | 6 +++++- app/streaming/video/ffmpeg-renderers/vt.mm | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index 55ecb497..841f4c99 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -1244,11 +1244,15 @@ void Session::toggleFullscreen() { bool fullScreen = !(SDL_GetWindowFlags(m_Window) & m_FullScreenFlag); -#ifdef Q_OS_WIN32 +#if defined(Q_OS_WIN32) || defined(Q_OS_DARWIN) // Destroy the video decoder before toggling full-screen because D3D9 can try // to put the window back into full-screen before we've managed to destroy // the renderer. This leads to excessive flickering and can cause the window // decorations to get messed up as SDL and D3D9 fight over the window style. + // + // On Apple Silicon Macs, the AVSampleBufferDisplayLayer may cause WindowServer + // to deadlock when transitioning out of fullscreen. Destroy the decoder before + // exiting fullscreen as a workaround. See issue #973. SDL_AtomicLock(&m_DecoderLock); delete m_VideoDecoder; m_VideoDecoder = nullptr; diff --git a/app/streaming/video/ffmpeg-renderers/vt.mm b/app/streaming/video/ffmpeg-renderers/vt.mm index 3a2d057d..1a84b1b8 100644 --- a/app/streaming/video/ffmpeg-renderers/vt.mm +++ b/app/streaming/video/ffmpeg-renderers/vt.mm @@ -112,6 +112,10 @@ public: if (m_DisplayLayer != nullptr) { [m_DisplayLayer release]; } + + // It appears to be necessary to run the event loop after destroying + // the AVSampleBufferDisplayLayer to avoid issue #973. + SDL_PumpEvents(); }} static