Crashed randomly when calling NewFrame

#1

I’m using the newest dx12/win32 version of imgui.

version number:
master - 526e2303bc1bfec7ca98e1328c15ce835cb47bc5 - May 4, 2019

When I call NewFrame() in the first frame the window crashes sometimes.
If I recompile or run it again the problem is gone, but it will always reappear later.
And my whole screen sometimes turned black when I start running my app. (I’m not sure if the black-screen problem was caused by ImGui)

IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;  // Enable Keyboard Controls
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;   // Enable Gamepad Controls

// Setup Dear ImGui style
ImGui::StyleColorsDark();
//ImGui::StyleColorsClassic();

// Setup Platform/Renderer bindings
ImGui_ImplWin32_Init(handleWnd);
ImGui_ImplDX12_Init(pDevice, NumFrameResources,
	DXGI_FORMAT_R8G8B8A8_UNORM,
	pDescriptorHeap->GetCPUDescriptorHandleForHeapStart(),
	pDescriptorHeap->GetGPUDescriptorHandleForHeapStart());

...
...
...


// Start the Dear ImGui frame
ImGui_ImplDX12_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();  //Crashed here

QQ%E5%9B%BE%E7%89%8720190504122515

#2

There’s no BeginFrame function in dear imgui. You are calling things through a GDxImGui wrapper and it would be better to ask whoever made this wrapper/setup/engine as we don’t know how it works.

#3

I’m sorry it’s just a typo. The title should be “Crashed randomly when calling NewFrame”
GDxImgui is my own wrapper and it simply calls NewFrame of ImGui
void GDxImgui::BeginFrame()
{
// Start the Dear ImGui frame
ImGui_ImplDX12_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
}

#4

Does the example_win32_dx12 demo works on your machine?

You should probably check what that HR value is…

1 Like
#5

The demo works fine, and imgui works fine in my engine most of the time_(:з」∠)_

After I run it 3 or 4 times this problem will occur once, and I have to recompile all the code to make it work again

#6

And I guess this problem only happens in dx12 version(

#7

I think I finally find the reason.
It seems Windows TDR caused this problem, not ImGui.
Still thank you so much for your reply. I should’ve checked the hr value first.(:з」∠)