From b2c5fdc39f850b01c9a8013756b0a80591c21d0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 22 Jul 2026 09:47:05 +0200 Subject: [PATCH] Make EmuThreadFunc match Android's EmuThreadFunc --- Core/EmuThread.cpp | 13 ++++++++++++- android/jni/app-android.cpp | 15 ++------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Core/EmuThread.cpp b/Core/EmuThread.cpp index 65cc06153d..4e21db6622 100644 --- a/Core/EmuThread.cpp +++ b/Core/EmuThread.cpp @@ -41,14 +41,22 @@ bool MainThread_Ready() { } static void EmuThreadFunc(GraphicsContext *graphicsContext, std::function postFrame) { + INFO_LOG(Log::G3D, "Entering emu thread"); SetCurrentThreadName("EmuThread"); + AndroidJNIThreadContext context; // There's no real requirement that NativeInit happen on this thread. // We just call the update/render loop here. g_emuThreadState = EmuThreadState::RUNNING; - NativeInitGraphics(graphicsContext); + if (!NativeInitGraphics(graphicsContext)) { + _assert_msg_(false, "NativeInitGraphics failed, might as well bail"); + // If this fails, which it normally shouldn't, let's bail. + g_emuThreadState = EmuThreadState::QUIT_REQUESTED; + } else { + INFO_LOG(Log::G3D, "EmuThread: Entering loop"); + } while (g_emuThreadState != EmuThreadState::QUIT_REQUESTED) { // We're here again, so the game quit. Restart Run() which controls the UI. @@ -63,9 +71,12 @@ static void EmuThreadFunc(GraphicsContext *graphicsContext, std::function postFrame) { diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index 83489d4fac..7ae8fc9cef 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -272,11 +272,7 @@ static void EmuThreadFunc() { INFO_LOG(Log::System, "Entering emu thread"); - // Wait for render loop to get started. - INFO_LOG(Log::System, "Runloop: Waiting for displayInit..."); - _dbg_assert_(graphicsContext); - - // Check the state of the graphics context before we try to feed it into NativeInitGraphics. + _assert_(graphicsContext); if (!NativeInitGraphics(graphicsContext)) { _assert_msg_(false, "NativeInitGraphics failed, might as well bail"); emuThreadState = (int)EmuThreadState::QUIT_REQUESTED; @@ -1754,14 +1750,7 @@ static void VulkanEmuThread(ANativeWindow *wnd) { AndroidJNIThreadContext ctx; JNIEnv *env = getEnv(); - - if (!graphicsContext) { - ERROR_LOG(Log::G3D, "runVulkanRenderLoop: Tried to enter without a created graphics context."); - renderLoopRunning = false; - exitRenderLoop = false; - ANativeWindow_release(wnd); - return; - } + _assert_(graphicsContext); if (exitRenderLoop) { WARN_LOG(Log::G3D, "runVulkanRenderLoop: ExitRenderLoop requested at start, skipping the whole thing.");