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.
This commit is contained in:
Dentomologist 2024-09-24 12:55:43 -07:00
parent de67c4c93b
commit 91f7b776ca
1 changed files with 1 additions and 1 deletions

View File

@ -300,7 +300,7 @@ void VideoBackendBase::PopulateBackendInfoFromUI(const WindowSystemInfo& wsi)
{ {
// If the core is running, the backend info will have been populated already. // 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 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); PopulateBackendInfo(wsi);
} }