From b6d7c18f3969509ee3f5b3f7e14d3d2ab3602b8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 3 Aug 2026 23:09:07 +0200 Subject: [PATCH] Try to eliminate a race condition --- Common/GPU/OpenGL/OpenGLGraphicsContext.cpp | 2 +- SDL/SDLMain.cpp | 12 ++++++------ UI/NativeApp.cpp | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Common/GPU/OpenGL/OpenGLGraphicsContext.cpp b/Common/GPU/OpenGL/OpenGLGraphicsContext.cpp index ae18492576..796255d0b9 100644 --- a/Common/GPU/OpenGL/OpenGLGraphicsContext.cpp +++ b/Common/GPU/OpenGL/OpenGLGraphicsContext.cpp @@ -28,7 +28,7 @@ bool OpenGLGraphicsContext::InitSurface(WindowSystem winsys, void *data1, void * } void OpenGLGraphicsContext::ShutdownSurface() { - INFO_LOG(Log::G3D, "OpenGLGraphicsContext::Shutdown"); + INFO_LOG(Log::G3D, "OpenGLGraphicsContext::ShutdownSurface"); renderManager_ = nullptr; // owned by draw_. delete draw_; draw_ = nullptr; diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index e84aa708e3..052bed6262 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -1333,17 +1333,17 @@ static void ProcessSDLEvent(SDL_Window *window, const SDL_Event &event, InputSta case SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED: { INFO_LOG(Log::UI, "SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED: %d x %d", event.window.data1, event.window.data2); - int new_width = event.window.data1; - int new_height = event.window.data2; + const int new_width = event.window.data1; + const int new_height = event.window.data2; Native_NotifyWindowHidden(false); Uint64 window_flags = SDL_GetWindowFlags(window); bool fullscreen = (window_flags & SDL_WINDOW_FULLSCREEN) != 0; - // !!! This is the wrong thread! - // This one calls NativeResized if the size changed. - Native_UpdateScreenScale(new_width, new_height, UIScaleFactorToMultiplier(g_Config.iUIScaleFactor)); + System_RunOnMainThread([new_width, new_height]() { + Native_UpdateScreenScale(new_width, new_height, UIScaleFactorToMultiplier(g_Config.iUIScaleFactor)); + }); // Set variable here in case fullscreen was toggled by hotkey if (g_Config.bFullScreen != fullscreen) { @@ -2130,7 +2130,7 @@ int main(int argc, char *argv[]) { float dpi_scale = 1.0f / (g_ForcedDPI == 0.0f ? g_DesktopDPI : g_ForcedDPI); - Native_UpdateScreenScale(w * g_DesktopDPI, h * g_DesktopDPI, UIScaleFactorToMultiplier(g_Config.iUIScaleFactor)); + // Native_UpdateScreenScale(w * g_DesktopDPI, h * g_DesktopDPI, UIScaleFactorToMultiplier(g_Config.iUIScaleFactor)); SDL_SetWindowTitle(window, (app_name_nice + " " + PPSSPP_GIT_VERSION).c_str()); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 829eb88889..34979f02d6 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1721,6 +1721,8 @@ static bool IsWindowSmall(int pixelWidth, int pixelHeight) { } bool Native_UpdateScreenScale(int pixel_width, int pixel_height, float customScale) { + INFO_LOG(Log::System, "Native_UpdateScreenScale: %dx%d, customScale=%f", pixel_width, pixel_height, customScale); + _dbg_assert_(customScale > 0.1f); float g_logical_dpi = System_GetPropertyFloat(SYSPROP_DISPLAY_LOGICAL_DPI); float dpi = System_GetPropertyFloat(SYSPROP_DISPLAY_DPI);