Fexty12573 / SharpPluginLoader

A C# plugin loader for Monster Hunter World
MIT License
32 stars 2 forks source link

Crash when switching game to windowed mode #13

Closed Andoryuuta closed 6 months ago

Andoryuuta commented 7 months ago

Summary

When switching the game to windowed mode from fullscreen at the title (using alt+enter), the game crashes with ERR11: Invalid GXGI call..

This appears to happen right after the hooked ResizeBuffers function has been called:

image

Reproduction steps

  1. Launch game (configured with fullscreen and DX12)
  2. Wait until the title screen has appeared
  3. Press Alt+Enter to switch to windowed mode
  4. Crash
Fexty12573 commented 7 months ago

I tried this twice, and got 2 different crashes. One is the invalid dxgi call, and the other one seems to happen inside the ImGui WndProc handler. The latter can be fixed simply by adding a check inside D3DModule::my_window_proc to see if m_is_initialized before calling ImGui_ImplWin32_WndProcHandler (since the ResizeBuffers hook calls ImGui_ImplWin32_Shutdown)

Fexty12573 commented 7 months ago

D3D Debug Layer Output when this happens:

DXGI ERROR: IDXGISwapChain::ResizeBuffers: Swapchain cannot be resized unless all outstanding buffer references have been released. [ MISCELLANEOUS ERROR #19: ]

Fexty12573 commented 7 months ago

Partially fixed in 15266c94970070204de7858a49e03d570b620ec3

Fexty12573 commented 6 months ago

Completely fixed in 314f5e79bf1bcf5e9638e117fe780cc4e28f529c. The reason for the crash was an infinite recursion inside my_window_proc due to a second SetWindowLongPtr call upon graphics device reset.