Skip to content

Conversation

@lut0pia
Copy link

@lut0pia lut0pia commented Nov 5, 2025

Hello,

We've been using ImGui at work for some time and while extending our usage recently I came upon an issue in ImGui::RenderDimmedBackgroundBehindWindow where the assert making sure that the draw commands were not merged fired. The circumstances seemed to meet when attempting to draw the window selection widget while moving another window into a new viewport/window with a gamepad (I'm sure some other specifics were involved but I don't know what they are). I saw the FIXME so I tried finding a way to avoid the issue without changing everything. This is working for us and I thought that it could work for others too, but I haven't found much discussion around that issue (possibly our setup really is that rare?).

For more context we're using this Unreal Engine plugin with a few minor changes to it (but AFAIK the issue is present in vanilla too).

One thing I don't know is if there's other places to check for that newly created boolean.

Hopefully this can be useful, thanks for this great piece of software!

@ocornut
Copy link
Owner

ocornut commented Nov 5, 2025

Hello Lou, thanks for your PR.

I realize the FIXME suggested that, but I would prefer to study/understand and fix the root issue better and I would need a repro.

Can you easily repro it and could you provide more information?
Which version are you precisely on? (IMGUI_VERSION_NUM value)

FYI the original code could be expanded with an earlier assert:

draw_list->PushClipRect(viewport_rect.Min - ImVec2(1, 1), viewport_rect.Max + ImVec2(1, 1), false); // FIXME: Need to stricty ensure ImDrawCmd are not merged (ElemCount==6 checks below will verify that)
ImDrawCmd cmd = draw_list->CmdBuffer.back();
IM_ASSERT(cmd.ElemCount == 0);
draw_list->AddRectFilled(viewport_rect.Min, viewport_rect.Max, col);
cmd = draw_list->CmdBuffer.back();
IM_ASSERT(cmd.ElemCount == 6);

Supposedly if the assert triggers it is because PushClipRect() did not create a new command.
If that happen you could technically move execution cursor back to the PushClipRect() call and try to understand why.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants