Crash on Ctrl+Tab for DockSpaceOverViewport with PassthruCentralNode flag #4792

Closed
opened 2021-12-08 13:56:13 +00:00 by ilovexyz · 12 comments
ilovexyz commented 2021-12-08 13:56:13 +00:00 (Migrated from github.com)

Version/Branch of Dear ImGui:

Version: 1.86 WIP (18516)
Branch: docking

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp
Compiler: MSVC
Operating System: Windows 10

My Issue/Question:

I want to use the ImGui::DockSpaceOverViewport function in my application, but it will cause crash when pressing Ctrl+Tab navigation key, i wonder if this is a bug or i didn't understand the usage of dockspace.

Screenshots/Video

Step to reproduce the issue based on the example_glfw_opengl3:

exception

Code crashes here:

exception

Standalone, minimal, complete and verifiable example:

Just add the following code to the main.cpp of example_glfw_opengl3 will reproduce the issue.

// show dock
ImGui::DockSpaceOverViewport(ImGui::GetMainViewport(), ImGuiDockNodeFlags_PassthruCentralNode);
code
**Version/Branch of Dear ImGui:** Version: 1.86 WIP (18516) Branch: docking **Back-end/Renderer/Compiler/OS** Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl3.cpp Compiler: MSVC Operating System: Windows 10 **My Issue/Question:** I want to use the ```ImGui::DockSpaceOverViewport``` function in my application, but it will cause crash when pressing Ctrl+Tab navigation key, i wonder if this is a bug or i didn't understand the usage of dockspace. **Screenshots/Video** Step to reproduce the issue based on the ```example_glfw_opengl3```: <img width="1283" alt="exception" src="https://user-images.githubusercontent.com/18619226/145219034-0ee3b74f-9aee-4157-9cec-a853b7443f5d.gif"> Code crashes here: <img width="824" alt="exception" src="https://user-images.githubusercontent.com/18619226/145219028-6597c873-592b-49c6-a7e7-901e204c1aa7.png"> **Standalone, minimal, complete and verifiable example:** Just add the following code to the main.cpp of ```example_glfw_opengl3``` will reproduce the issue. ``` // show dock ImGui::DockSpaceOverViewport(ImGui::GetMainViewport(), ImGuiDockNodeFlags_PassthruCentralNode); ``` <img width="799" alt="code" src="https://user-images.githubusercontent.com/18619226/145219024-146ef94b-d11e-4cb2-9ec7-e210b4549436.png">
ocornut commented 2021-12-08 14:18:27 +00:00 (Migrated from github.com)

This is code we changed recently. Can you confirm if updating to very latest commit still reproduce the issue?

This is code we changed recently. Can you confirm if updating to very latest commit still reproduce the issue?
ilovexyz commented 2021-12-08 14:36:11 +00:00 (Migrated from github.com)

yes, i just pull the lastest docking branch, the above issue is running using the lastest code

> yes, i just pull the lastest docking branch, the above issue is running using the lastest code
ilovexyz commented 2021-12-08 14:47:28 +00:00 (Migrated from github.com)

This is code we changed recently. Can you confirm if updating to very latest commit still reproduce the issue?

if add the following code before accessing CmdBuffer.Data, it will crash elsewhere.

    if (CmdBuffer.Size == 0)
        return;

from the debug stack, i can see the value of CmdBuffer.Size is zero, but i don't know how to correct this.

> This is code we changed recently. Can you confirm if updating to very latest commit still reproduce the issue? if add the following code before accessing ```CmdBuffer.Data```, it will crash elsewhere. ``` if (CmdBuffer.Size == 0) return; ``` from the debug stack, i can see the value of ```CmdBuffer.Size``` is zero, but i don't know how to correct this.
ocornut commented 2021-12-08 16:07:31 +00:00 (Migrated from github.com)

Should be fixed by 0647cf4, thank you very much for reporting and helping!

Should be fixed by 0647cf4, thank you very much for reporting and helping!
ilovexyz commented 2021-12-08 16:14:36 +00:00 (Migrated from github.com)

wow, thank you for the quick response, i just pulled and checked, no crash any more!

wow, thank you for the quick response, i just pulled and checked, no crash any more!
RT2Code commented 2022-01-24 13:36:43 +00:00 (Migrated from github.com)

I stumbled upon the same issue while migrating to imgui 1.87 wip (docking branch). It seems to happens only with empty windows. You can reproduce it like this :

const ImGuiID dock_id = ImGui::DockSpaceOverViewport(ImGui::GetMainViewport());
ImGui::SetNextWindowDockID(dock_id, ImGuiCond_FirstUseEver);
ImGui::Begin("Window");
ImGui::End();

A Begin followed by and End call will always result in a crash if the window is docked and reached with ctrl+tab. This can also be reproduced with the log or long text display windows of the imgui demos because theses windows have such a code path.

I stumbled upon the same issue while migrating to imgui 1.87 wip (docking branch). It seems to happens only with empty windows. You can reproduce it like this : ``` const ImGuiID dock_id = ImGui::DockSpaceOverViewport(ImGui::GetMainViewport()); ImGui::SetNextWindowDockID(dock_id, ImGuiCond_FirstUseEver); ImGui::Begin("Window"); ImGui::End(); ``` A Begin followed by and End call will always result in a crash if the window is docked and reached with ctrl+tab. This can also be reproduced with the log or long text display windows of the imgui demos because theses windows have such a code path.
ocornut commented 2022-01-24 13:56:33 +00:00 (Migrated from github.com)

Thank you, will look into fixing soon.

Thank you, will look into fixing soon.
ocornut commented 2022-01-25 11:05:07 +00:00 (Migrated from github.com)

@RT222 I cannot reproduce a crash. Can you post details and a callstack? What is your backend and your config flags? (best to Copy the build info available in About box).

I however noticed that during CTRL+Tabbing the background color of the viewport will start appearing above non-docked windows which is most likely due to the BgColor/dimming changes done in 1.86.

@RT222 I cannot reproduce a crash. Can you post details and a callstack? What is your backend and your config flags? (best to Copy the build info available in About box). **I however noticed that during CTRL+Tabbing the background color of the viewport will start appearing above non-docked windows which is most likely due to the BgColor/dimming changes done in 1.86.**
RT2Code commented 2022-01-25 13:01:50 +00:00 (Migrated from github.com)

Using the latest docking commit (ocornut/imgui@08f3aa8972) and the default imgui examples files without any modification, I was able to reproduce this crash consistently on all win32 and sdl2 based backends by docking the log window on the main viewport.

Then I tried to test more build configurations and I think I found why you couldn't reproduce it on your end : it only happens on 64 bits builds. Try it with any backend built on debug/64bits, and I'm pretty confident you should get this crash too.

Here's my build infos :

Dear ImGui 1.87 WIP (18612)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=199711
define: _WIN32
define: _WIN64
define: _MSC_VER=1930
define: _MSVC_LANG=201402
define: IMGUI_HAS_VIEWPORT
define: IMGUI_HAS_DOCK
--------------------------------
io.BackendPlatformName: imgui_impl_win32
io.BackendRendererName: imgui_impl_dx11
io.ConfigFlags: 0x00000441
 NavEnableKeyboard
 DockingEnable
 ViewportsEnable
io.ConfigViewportsNoDecoration
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00001C0E
 HasMouseCursors
 HasSetMousePos
 PlatformHasViewports
 HasMouseHoveredViewport
 RendererHasVtxOffset
 RendererHasViewports
--------------------------------
io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,64
io.DisplaySize: 1264.00,761.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 0.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00
Using the latest docking commit (https://github.com/ocornut/imgui/commit/08f3aa89723f8e41a8b10aa0c60c6617da563e18) and the default imgui examples files without any modification, I was able to reproduce this crash consistently on all win32 and sdl2 based backends by docking the log window on the main viewport. Then I tried to test more build configurations and I think I found why you couldn't reproduce it on your end : it only happens on 64 bits builds. Try it with any backend built on debug/64bits, and I'm pretty confident you should get this crash too. Here's my build infos : ``` Dear ImGui 1.87 WIP (18612) -------------------------------- sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20 define: __cplusplus=199711 define: _WIN32 define: _WIN64 define: _MSC_VER=1930 define: _MSVC_LANG=201402 define: IMGUI_HAS_VIEWPORT define: IMGUI_HAS_DOCK -------------------------------- io.BackendPlatformName: imgui_impl_win32 io.BackendRendererName: imgui_impl_dx11 io.ConfigFlags: 0x00000441 NavEnableKeyboard DockingEnable ViewportsEnable io.ConfigViewportsNoDecoration io.ConfigInputTextCursorBlink io.ConfigWindowsResizeFromEdges io.ConfigMemoryCompactTimer = 60.0 io.BackendFlags: 0x00001C0E HasMouseCursors HasSetMousePos PlatformHasViewports HasMouseHoveredViewport RendererHasVtxOffset RendererHasViewports -------------------------------- io.Fonts: 1 fonts, Flags: 0x00000000, TexSize: 512,64 io.DisplaySize: 1264.00,761.00 io.DisplayFramebufferScale: 1.00,1.00 -------------------------------- style.WindowPadding: 8.00,8.00 style.WindowBorderSize: 1.00 style.FramePadding: 4.00,3.00 style.FrameRounding: 0.00 style.FrameBorderSize: 0.00 style.ItemSpacing: 8.00,4.00 style.ItemInnerSpacing: 4.00,4.00 ```
ocornut commented 2022-01-25 16:30:22 +00:00 (Migrated from github.com)

Thank you I have managed to repro. It is possible to get a better assert with #define IMGUI_DEBUG_PARANOID in imconfig.h

Pushed a fix f1a0731
It's embarrassing how many regressions those window dimming/bgcolor system changes caused :(

Leaving this open because of :
> I however noticed that during CTRL+Tabbing the background color of the viewport will start appearing above non-docked windows which is most likely due to the BgColor/dimming changes done in 1.86.

Thank you I have managed to repro. It is possible to get a better assert with `#define IMGUI_DEBUG_PARANOID` in imconfig.h Pushed a fix f1a0731 It's embarrassing how many regressions those window dimming/bgcolor system changes caused :( Leaving this open because of : **> I however noticed that during CTRL+Tabbing the background color of the viewport will start appearing above non-docked windows which is most likely due to the BgColor/dimming changes done in 1.86.**
RT2Code commented 2022-01-25 16:55:42 +00:00 (Migrated from github.com)

Everything is working fine now, thanks for the quick fix.

Everything is working fine now, thanks for the quick fix.
ocornut commented 2022-11-24 20:20:30 +00:00 (Migrated from github.com)

Leaving this open because of :
I however noticed that during CTRL+Tabbing the background color of the viewport will start appearing above non-docked windows which is most likely due to the BgColor/dimming changes done in 1.86.

Moving this to #5917 as main issue here has been fixed a while ago.

> Leaving this open because of : > I however noticed that during CTRL+Tabbing the background color of the viewport will start appearing above non-docked windows which is most likely due to the BgColor/dimming changes done in 1.86. Moving this to #5917 as main issue here has been fixed a while ago.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#4792
No description provided.