Skip to content

Commit

Permalink
Core: Don't consider graphics failed on shutdown.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
unknownbrackets committed Sep 6, 2018
1 parent db93a08 commit fb8f408
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions UI/NativeApp.cpp
Expand Up @@ -346,6 +346,14 @@ void CreateDirectoriesAndroid() {
} }


static void CheckFailedGPUBackends() { 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"; std::string cache = GetSysDirectory(DIRECTORY_APP_CACHE) + "/FailedGraphicsBackends.txt";


if (System_GetPropertyBool(SYSPROP_SUPPORTS_PERMISSIONS)) { if (System_GetPropertyBool(SYSPROP_SUPPORTS_PERMISSIONS)) {
Expand All @@ -361,10 +369,9 @@ static void CheckFailedGPUBackends() {
ERROR_LOG(LOADER, "Failed graphics backends: %s", g_Config.sFailedGPUBackends.c_str()); ERROR_LOG(LOADER, "Failed graphics backends: %s", g_Config.sFailedGPUBackends.c_str());


// Okay, let's not try a backend in the failed list. // Okay, let's not try a backend in the failed list.
int newBackend = g_Config.NextValidBackend(); g_Config.iGPUBackend = g_Config.NextValidBackend();
if (newBackend != g_Config.iGPUBackend) if (lastBackend != g_Config.iGPUBackend)
WARN_LOG(LOADER, "Failed graphics backend switched from %d to %d", g_Config.iGPUBackend, newBackend); WARN_LOG(LOADER, "Failed graphics backend switched from %d to %d", lastBackend, g_Config.iGPUBackend);
g_Config.iGPUBackend = newBackend;
// And then let's - for now - add the current to the failed list. // And then let's - for now - add the current to the failed list.
if (g_Config.sFailedGPUBackends.empty()) { if (g_Config.sFailedGPUBackends.empty()) {
g_Config.sFailedGPUBackends = StringFromFormat("%d", g_Config.iGPUBackend); g_Config.sFailedGPUBackends = StringFromFormat("%d", g_Config.iGPUBackend);
Expand Down

0 comments on commit fb8f408

Please sign in to comment.