close
Skip to content

Multi-viewport : crash at exit when backend code is in a DLL #8945

@olivier-gerard

Description

@olivier-gerard

Version/Branch of Dear ImGui:

Version 1.92.3, Branch: docking

Back-ends:

imgui_impl_vulkan.cpp + imgui_impl_glfw.cpp

Compiler, OS:

Windows 11 + visual studio

Full config/build information:

No response

Details:

I just moved on to the docking branch and experience a crash at app exit.
A specificity of my code is that the backend code is in a DLL : the app creates the context, the DLL imports it.
Then at each frame, basically the DLL call NewFrame(), call callback for the app the create the GUI, then the DLL call Render().
This is not the most efficient scheme but I had to do so due to internal constraints (the DLL contains specific vulkan code and is also used by other apps).
Well, I had no issue with the master branch, and now it crashes with docking.

The issue come frome the fact that ImGui_ImplVulkan_InitMultiViewportSupport and ImGui_ImplVulkan_ShutdownMultiViewportSupport are not symetrical.
The init sets many function pointers (eg platform_io.Renderer_DestroyWindow = ImGui_ImplVulkan_DestroyWindow;), which are not valid once the DLL is terminated.
I suggest that the shutdown function, after calling ImGui::DestroyPlatformWindows(); shall clear the callbacks. So when DestroyPlatformWindows will be called by DestroyContext it will just do nothing.
Or maybe removing the call to DestroyPlatformWindows in Shutdown, as it was already done by the backend ?

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions