From ad9c65ae398e87a0703bc504798ab3cc8780fb9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 27 Oct 2026 22:11:09 +0100 Subject: [PATCH] EmuThread: Run the graphics context's ThreadStart before starting the emu thread On OpenGL the render thread's ThreadStart fills in the GL strings and picks the buffer strategy, while the emu thread, started just before it, could already be in NativeInitGraphics reading them. A Play report crashed walking the strings map in BuildReportingInfo. ThreadStart also resets the exit flags, which could undo an early exit by the emu thread. Libretro already starts its emu thread in this order. Co-Authored-By: Claude Opus 5.5 --- Core/EmuThread.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Core/EmuThread.cpp b/Core/EmuThread.cpp index 10aababd5f..90483fdb81 100644 --- a/Core/EmuThread.cpp +++ b/Core/EmuThread.cpp @@ -79,9 +79,10 @@ static void EmuThreadFunc(GraphicsContext *graphicsContext, Application *applica std::thread EmuThread_Start(GraphicsContext *graphicsContext, Application *application, std::function frame) { INFO_LOG(Log::System, "EmuTread_Start"); _dbg_assert_(g_emuThreadState == EmuThreadState::STOPPED); - std::thread emuThread = std::thread(&EmuThreadFunc, graphicsContext, application, frame); + // Before the emu thread exists: ThreadStart sets up state that NativeInitGraphics reads (the GL + // strings for reporting), and resets the exit flags the emu thread sets. graphicsContext->ThreadStart(); - return emuThread; + return std::thread(&EmuThreadFunc, graphicsContext, application, frame); } // This is useful when the render thread is in control.