From fb8f408db010943b5dc90ee090e7efece1662c61 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 6 Sep 2018 07:31:15 -0700 Subject: [PATCH] Core: Don't consider graphics failed on shutdown. On some devices, we'll lose context or get a resize mid-startup, so make sure we don't detect that as a graphics crash. --- UI/NativeApp.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 9c1610718b5b..c85c1ea6a5ff 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -346,6 +346,14 @@ void CreateDirectoriesAndroid() { } static void CheckFailedGPUBackends() { + // We only want to do this once per process run and backend, to detect process crashes. + // If NativeShutdown is called before we finish, we might call this multiple times. + static int lastBackend = -1; + if (lastBackend == g_Config.iGPUBackend) { + return; + } + lastBackend = g_Config.iGPUBackend; + std::string cache = GetSysDirectory(DIRECTORY_APP_CACHE) + "/FailedGraphicsBackends.txt"; if (System_GetPropertyBool(SYSPROP_SUPPORTS_PERMISSIONS)) { @@ -361,10 +369,9 @@ static void CheckFailedGPUBackends() { ERROR_LOG(LOADER, "Failed graphics backends: %s", g_Config.sFailedGPUBackends.c_str()); // Okay, let's not try a backend in the failed list. - int newBackend = g_Config.NextValidBackend(); - if (newBackend != g_Config.iGPUBackend) - WARN_LOG(LOADER, "Failed graphics backend switched from %d to %d", g_Config.iGPUBackend, newBackend); - g_Config.iGPUBackend = newBackend; + g_Config.iGPUBackend = g_Config.NextValidBackend(); + if (lastBackend != g_Config.iGPUBackend) + WARN_LOG(LOADER, "Failed graphics backend switched from %d to %d", lastBackend, g_Config.iGPUBackend); // And then let's - for now - add the current to the failed list. if (g_Config.sFailedGPUBackends.empty()) { g_Config.sFailedGPUBackends = StringFromFormat("%d", g_Config.iGPUBackend);