Skip to content

Docking: Crash when opening popup on the first frame of rendering #5401

Closed
@spp-mattp

Description

Version/Branch of Dear ImGui:

Version: 1.87
Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_win32 + imgui_impl_dx11
Compiler: MSVC 2017 (v141 build tools)
Operating System: Windows 10

My Issue/Question:

I am running into an issue where opening a popup on the first frame of rendering triggers a crash when using a dockspace. The crash occurs during Begin() in any window after the popup is opened. Specifically, it happens in ImGui::FindBlockingModal,
because parent->ParentWindowInBeginStack is null.

Also worth noting, it seems to be affected by saved window positions/docking state - I was getting inconsistent repros
until I started deleting imgui.ini before running.

We are currently working around the issue by just not issuing any calls to open popups on the first frame of rendering.

Standalone, minimal, complete and verifiable example:

ImGui::Begin("Root");

// Setup dockspace 

ImGuiID imidRootDockspace = ImGui::GetID("RootDockspace");
ImGui::DockSpace(imidRootDockspace);

static bool s_fRootDockspaceIsSetup = false;

if (!s_fRootDockspaceIsSetup)
{
      s_fRootDockspaceIsSetup = true;

      ImGuiID imidSplitNode1 = 0;
      ImGuiID imidSplitNode2 = ImGui::DockBuilderSplitNode(imidRootDockspace, ImGuiDir_Right, 0.42f, NULL, &imidSplitNode1);

      ImGui::DockBuilderDockWindow("WindowWithPopup", imidSplitNode1);
      ImGui::DockBuilderDockWindow("WindowAfterPopup", imidSplitNode2);
      ImGui::DockBuilderFinish(imidRootDockspace);
}

ImGui::End(); // Root Window

ImGui::Begin("WindowWithPopup");

if (!ImGui::IsPopupOpen("popup"))
      ImGui::OpenPopup("popup");
if (ImGui::BeginPopupModal("popup"))
      ImGui::EndPopup();

ImGui::End();

// Crash occurs here (in Begin()), specifically in ImGui::FindBlockingModal because parent->ParentWindowInBeginStack is null

ImGui::Begin("WindowAfterPopup");
ImGui::End();

Activity

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

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions