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

IM_ASSERT(viewport->RendererUserData == NULL && viewport->PlatformUserData == NULL) in ImGui_ImplWin32_Shutdown() #4941

Closed
SimpsonGSD opened this issue Jan 25, 2022 · 6 comments

Comments

@SimpsonGSD
Copy link

SimpsonGSD commented Jan 25, 2022

Version/Branch of Dear ImGui:

Version: f1a0731
Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_win32.cpp + imgui_impl_vulkan.cpp
Compiler: msvc
Operating System: Windows 10

My Issue/Question:

Hi, I am getting the assert IM_ASSERT(viewport->RendererUserData == NULL && viewport->PlatformUserData == NULL); when calling ImGui_ImplWin32_Shutdown() .

I have ImGuiConfigFlags_DockingEnable but not ImGuiConfigFlags_ViewportsEnable.

Should the call to ImGui_ImplWin32_ShutdownPlatformInterface(); be wrapped in if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) like ImGui_ImplWin32_InitPlatformInterface()?
Doing this fixes my issue but it could also be user error on my part.

Thanks.

@SimpsonGSD SimpsonGSD changed the title IM_ASSERT(viewport->RendererUserData == NULL && viewport->PlatformUserData == NULL); in ImGui_ImplDX12_Shutdown() IM_ASSERT(viewport->RendererUserData == NULL && viewport->PlatformUserData == NULL) in ImGui_ImplDX12_Shutdown() Jan 25, 2022
@ocornut
Copy link
Owner

ocornut commented Jan 25, 2022

ImGui_ImplDX12_Shutdown
imgui_impl_vulkan.cpp

Please clarify the inconsistency above.

Also please test and see if it happens with stock examples.
Thank you :)

@SimpsonGSD SimpsonGSD changed the title IM_ASSERT(viewport->RendererUserData == NULL && viewport->PlatformUserData == NULL) in ImGui_ImplDX12_Shutdown() IM_ASSERT(viewport->RendererUserData == NULL && viewport->PlatformUserData == NULL) in ImGui_ImplWin32_Shutdown() Jan 25, 2022
@SimpsonGSD
Copy link
Author

Apologies! Updated - it should say Win32 not DX12..
I will test the examples.

@ocornut
Copy link
Owner

ocornut commented Jan 26, 2022

Basically the assert imply you should shutdown the renderer backend before the platform backend.
But as per #4656 and bac748f we supposedly lifted that, so it is strange.
If I swap the calls in example_win32_directx11/main.cpp it still works.
So you will need to investigate what else you may be doing wrong....

Normally either backend would end up calling ImGui::DestroyPlatformWindows() which will call through the g.PlatformIO.Renderer_DestroyWindow() and g.PlatformIO.Platform_DestroyWindow() handler for all viewports.

@SimpsonGSD
Copy link
Author

I tested the examples and could not reproduce - though there is no combination of win32+vulkan I still couldn't repro in examples that used one of these.
I am indeed shutting down the platform before the renderer. I will try reversing them.

@SimpsonGSD
Copy link
Author

I called ImGui_ImplVulkan_Shutdown() before ImGui_ImplWin32_Shutdown() but then I get a different assert:
IM_ASSERT(bd != NULL && "No platform backend to shutdown, or already shutdown?");

@SimpsonGSD
Copy link
Author

Found the issue.
Originally I was calling
ImGui_ImplWin32_Shutdown() then
ImGui_ImplVulkan_Shutdown()

I swapped them around and got a different assert but what I actually found was this order
ImGui_ImplVulkan_Shutdown()
ImGui::DestroyContext()
ImGui_ImplWin32_Shutdown()

Changing it to the expected order is fine:
ImGui_ImplVulkan_Shutdown()
ImGui_ImplWin32_Shutdown()
ImGui::DestroyContext()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants