Emulator Issues #9723closed
Dolphin hanging forever when launching any Wii games in full screen + DX11
Emulator hanging forever if launch any Wii games in full screen + DX11.
It doesn't hang if you launch game in windowed mode and then switch to full screen.
It applies only to dev builds 5.0+ but doesn't applies to stable 5.0.
Also it doesn't hang with DX12 at all.
Tried delete profile folder - doesn't help.
Specs: i7-4770, gtx760, win10 x64
Updated by Kyogre over 7 years ago
same problem for few other users here https://github.com/dolphin-emu/dolphin/pull/3510#issuecomment-230109827
Updated by seapancake over 7 years ago
Good fine, this narrows it down to https://github.com/dolphin-emu/dolphin/pull/3510 possibly having an infinite. I'm locked out of the forums due to bad password attempts, would suggest contacting akyryz to get him to put debugging information here. and badkarma12 so we can compare your exact setups.
Also worth contacting JMC47 (IRC or forums) to see if he replicate it.
Updated by JosJuice over 7 years ago
- Subject changed from Dolphin hanging forever when launch any games in full screen + DX11 to Dolphin hanging forever when launching any Wii games in full screen + DX11
- Status changed from New to Accepted
- Priority changed from Normal to High
- Regression changed from No to Yes
- Regression start set to 5.0-76
- Operating system Windows added
- Operating system deleted (
This has been bisected down to PR 3510 for a while already.
There are some more criteria for triggering the bug than what's described in this issue report. I think it was something like exclusive fullscreen on, or render to main window off, or both.
Updated by Kyogre about 7 years ago
you are right about criteria.
Render to main window OFF + Borderless full screen OFF = hangs
Render to main window ON + Borderless full screen OFF = doesn't hang
Render to main window OFF + Borderless full screen ON = hangs
Render to main window ON + Borderless full screen ON = doesn't hang
Updated by Armada about 7 years ago
The problem here is that Dolphin violates the DXGI: Best Practices, which states that you should never lock the UI thread on the GPU thread. The reason for that is because DXGI (which runs on the GPU thread) will also send messages to the UI thread. This means there is a lot of potential for rare race conditions that deadlock the emulator.
This race condition has been known since exclusive fullscreen was first implemented, however it seems PR 3510 has exposed it due to changes in the initialization order. Here's what's happening:
- The GPU thread is initialized and DXGI sends some messages to the UI thread for initialization.
- The UI thread triggers a switch to fullscreen as the "Use Fullscreen" option is enabled.
- The GPU thread switches to exclusive fullscreen and DXGI sends some message to the UI thread to change its style.
- The UI thread calls UpdateGUI() which is called numerous times and includes a LockAndPause() which locks on the GPU thread.
- Both threads are now deadlocked with the GUI thread waiting on the UI thread to handle the message and the UI thread waiting on the GPU thread to pause.
There are two ways to solve this as documented in the DXGI Best Practices:
Hard way: "To avoid this, never block the message pump."
This requires we make any interaction with the GPU thread asynchronous, which is difficult given the numerous usages of LockAndPause(). Though never blocking the UI thread is generally good practice.
Easy way: "If a block is unavoidable, then all DXGI interaction should occur on the same thread as the message pump."
This would either involve moving the Render Window to the GPU thread (which means render-to-main is no longer possible) or making sure that after initialization of the backend all DXGI calls are done by the UI thread. I'll make an attempt at implementing the latter option.
Updated by Armada about 7 years ago
- Status changed from Accepted to Fix pending
A workaround is available in my new PR: https://github.com/dolphin-emu/dolphin/pull/4433
I'm also working on a PR for exclusive mode that has some of the stability improvements I outlined in my previous comment.