From a7b85605e2b3acc467a75833c0b311bfbc8f1fde Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 19 Sep 2020 13:04:32 +1000 Subject: [PATCH] Ignore existing surface size on Android Seems to be a race condition here where it's not up to date. --- android/app/src/cpp/android_host_interface.cpp | 6 +++++- src/common/gl/context_egl.cpp | 9 +++++++-- src/common/vulkan/swap_chain.cpp | 2 ++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/android/app/src/cpp/android_host_interface.cpp b/android/app/src/cpp/android_host_interface.cpp index 4dce585b8..37013605b 100644 --- a/android/app/src/cpp/android_host_interface.cpp +++ b/android/app/src/cpp/android_host_interface.cpp @@ -155,6 +155,8 @@ void AndroidHostInterface::LoadSettings() CommonHostInterface::LoadSettings(m_settings_interface); CommonHostInterface::FixIncompatibleSettings(false); CommonHostInterface::UpdateInputMap(m_settings_interface); + g_settings.log_level = LOGLEVEL_INFO; + g_settings.log_to_debug = true; } void AndroidHostInterface::UpdateInputMap() @@ -392,7 +394,7 @@ void AndroidHostInterface::OnRunningGameChanged() void AndroidHostInterface::SurfaceChanged(ANativeWindow* surface, int format, int width, int height) { - ReportFormattedMessage("SurfaceChanged %p %d %d %d", surface, format, width, height); + Log_InfoPrintf("SurfaceChanged %p %d %d %d", surface, format, width, height); if (m_surface == surface) { if (m_display) @@ -499,6 +501,8 @@ void AndroidHostInterface::ApplySettings(bool display_osd_messages) Settings old_settings = std::move(g_settings); CommonHostInterface::LoadSettings(m_settings_interface); CommonHostInterface::FixIncompatibleSettings(display_osd_messages); + g_settings.log_level = LOGLEVEL_INFO; + g_settings.log_to_debug = true; CheckForSettingsChanges(old_settings); } diff --git a/src/common/gl/context_egl.cpp b/src/common/gl/context_egl.cpp index 2f90c068d..15d555904 100644 --- a/src/common/gl/context_egl.cpp +++ b/src/common/gl/context_egl.cpp @@ -89,19 +89,24 @@ bool ContextEGL::ChangeSurface(const WindowInfo& new_wi) void ContextEGL::ResizeSurface(u32 new_surface_width /*= 0*/, u32 new_surface_height /*= 0*/) { + // This seems to race on Android... +#ifndef ANDROID EGLint surface_width, surface_height; if (eglQuerySurface(m_display, m_surface, EGL_WIDTH, &surface_width) && eglQuerySurface(m_display, m_surface, EGL_HEIGHT, &surface_height)) { m_wi.surface_width = static_cast(surface_width); m_wi.surface_height = static_cast(surface_height); + return; } else { Log_ErrorPrintf("eglQuerySurface() failed: %d", eglGetError()); - m_wi.surface_width = new_surface_width; - m_wi.surface_height = new_surface_height; } +#endif + + m_wi.surface_width = new_surface_width; + m_wi.surface_height = new_surface_height; } bool ContextEGL::SwapBuffers() diff --git a/src/common/vulkan/swap_chain.cpp b/src/common/vulkan/swap_chain.cpp index 9a1cd78d5..c7c0f686b 100644 --- a/src/common/vulkan/swap_chain.cpp +++ b/src/common/vulkan/swap_chain.cpp @@ -333,7 +333,9 @@ bool SwapChain::CreateSwapChain() // Determine the dimensions of the swap chain. Values of -1 indicate the size we specify here // determines window size? VkExtent2D size = surface_capabilities.currentExtent; +#ifndef ANDROID if (size.width == UINT32_MAX) +#endif { size.width = m_wi.surface_width; size.height = m_wi.surface_height;