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.");