Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DX12 example app crashes immediately after going into fullscreen #4346

Closed
0x90d opened this issue Jul 21, 2021 · 2 comments
Closed

DX12 example app crashes immediately after going into fullscreen #4346

0x90d opened this issue Jul 21, 2021 · 2 comments

Comments

@0x90d
Copy link

0x90d commented Jul 21, 2021

Version/Branch of Dear ImGui:

Version: master
Branch: master

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_d3d12.cpp
Compiler: VS 2019
Operating System: Win11

My Issue/Question:

DX12 example crashes (or freezes when its being debugged) as soon as you go fullscreen (ALT+RETURN). Tested in debug mode targeting x64. This issue might be related to a similar issue I've noticed in my own implementation. An investigation would be appreciated.

Screenshots/Video

It's hard to make a screenshot because once in fullscreen the application freezes up and I cannot alt+tab to another. The frozen example app stays in foreground. I think the crash occurs in ResizeSwapChain event. VS outputs this:

Exception thrown: read access violation.
**swapChain1** was nullptr.

Standalone, minimal, complete and verifiable example:
Download master branch or clone it, target x64 and launch DX12 example application. Hit ALT+RETURN.

@PathogenDavid
Copy link
Contributor

PathogenDavid commented Jul 21, 2021

Submitted a PR to fix this: #4347 #4348


Basically this is happening because we're recreating the whole swap chain instead of just resizing it.

Creating a swap chain for a window that's already fullscreen isn't considered best practice in the first place, and we aren't even doing it correctly if we were trying to do it the legacy way. (Basically we're trying to create a swapchain for a window which was automatically transitioned into a fullscreen state.)

(Note that if you're modeling your own Direct3D app off of this sample, using DXGI's automatic fullscreen transitions or SetFullscreenState is not something I would consider to be modern best practice for Windows 10. It's good enough for samples though.)

PathogenDavid added a commit to PathogenPlayground/imgui that referenced this issue Jul 21, 2021
This also removes unnecessary invalidation and recreation of backend-owned device objects when the window is resized.
Fixes ocornut#4346
PathogenDavid added a commit to PathogenPlayground/imgui that referenced this issue Jul 21, 2021
This also removes unnecessary recreation of backend-owned device objects when the window is resized.
Fixes ocornut#4346
ocornut pushed a commit that referenced this issue Jul 26, 2021
…#4346, #4348)

This also removes unnecessary recreation of backend-owned device objects when the window is resized.
+ amend original PR with a g_pSwapChain->SetFullscreenState(false, NULL); call.
@ocornut
Copy link
Owner

ocornut commented Jul 26, 2021

Fixed by #4348, thank you @PathogenDavid !

@ocornut ocornut closed this as completed Jul 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants