From 91f7b776ca51b06f33e72c92854a960c2fbaad8b Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Tue, 24 Sep 2024 12:55:43 -0700 Subject: [PATCH] GraphicsWindow: Fix crash when opening during emulation startup Fix a crash when opening the Graphics window for the first time during emulation startup when the backend is Vulkan, D3D11, or D3D12. Don't call PopulateBackendInfo() from the Host thread when the core is starting up. First, the function has already been called in Core::Init() so we don't need to again. More importantly, PopulateBackendInfo() calls g_video_backend->InitBackendInfo(), and the Vulkan and D3D implementations of those functions load and then unload libraries (and their associated function pointers) which are potentially in use by other threads. This crash was reliably reproducible with the following steps: 1) Select an affected backend. 2) Enable "Compile Shaders Before Starting" 3) Delete the cached shaders (but not the .uidcache file) for the game you're testing. 4) Close and reopen Dolphin. 5) Start the game. 6) While the game is still booting or compiling shaders, open the Graphics window for the first time in that Dolphin session. Fixes https://bugs.dolphin-emu.org/issues/13634. --- Source/Core/VideoCommon/VideoBackendBase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/VideoCommon/VideoBackendBase.cpp b/Source/Core/VideoCommon/VideoBackendBase.cpp index 1db7fb2ab6..0bbc734e3b 100644 --- a/Source/Core/VideoCommon/VideoBackendBase.cpp +++ b/Source/Core/VideoCommon/VideoBackendBase.cpp @@ -300,7 +300,7 @@ void VideoBackendBase::PopulateBackendInfoFromUI(const WindowSystemInfo& wsi) { // If the core is running, the backend info will have been populated already. // If we did it here, the UI thread can race with the with the GPU thread. - if (!Core::IsRunning(Core::System::GetInstance())) + if (!Core::IsRunningOrStarting(Core::System::GetInstance())) PopulateBackendInfo(wsi); }